#6687
Support 1a
Participant

    The fields available in a given address book vary between book to book. You need to query the field definitions contained in an address book to obtain a list of possible fields. The applet shown below creates a text file containing the field definition details for a given address book.

    Regarding your second question, while I haven’t tried, I would suspect the “Last reference” and “reference Count” fields should be accessible in the same way as all the other fields (they appear as standard fields in the output of the applet shown below). What kind of problem have you experienced?

    Advansys Support

    '-------------------------------------------------------------------------------
    ' Formativ Solutions for GroupWise
    ' Address Book Field Definitions
    ' Copyright (c) 2003 Advansys Pty Limited (www.advansyscorp.com)
    ' Version 1.0
    ' 
    ' DESCRIPTION:
    ' Fields definitions from the selected address book are saved to a text file.
    ' 
    ' 
    ' Display Format  : Name, Field type*, Field ID, Hidden*, Read only*
    ' * Field Type    : 1 - String, 2 - Numeric, 3 - Date, 4 - Binary, 5 - Reserved
    ' * Hidden        : Boolean. TRUE if the field is hidden.
    ' * Read Only     : Boolean. TRUE if the field is read-only
    '       
    '-------------------------------------------------------------------------------
    
    IDS_SEPARATOR             = Chr(9)
    const IDS_CAPTION         = "Formativ Business Solutions"
    const MAX_PAD             = 50
    
    
    '-------------------------------------------------------------------------------
    ' Main-Line Processing
    '-------------------------------------------------------------------------------
    Sub Main(Client, GWEvent)
      
      dim x
      dim iField
      dim iFieldDefs
      dim iFieldsList
      dim iAddressBook
      dim iAddressBookName
      
      on error resume next
      
      if not PrepareAddressBookDlg(iAddressBookName) then
        exit sub
      end if
      
      set iAddressBook = GroupWise.AddressBooks.item(iAddressBookName).object
      
      if not isobject(iAddressBook) then
        exit sub
      end if
      
      set iFieldsList = utilities.stringlist
      set iFieldDefs = iAddressBook.FieldDefinitions
      
      iFieldsList.add("Address book: " & iAddressBook.name)
      iFieldsList.add("Field Definitions: " & iFieldDefs.count)
      iFieldsList.add("Key: Name, Field type, Field ID, Hidden, Read only")
      iFieldsList.add("Field type: 1 - String, 2 - Numeric, 3 - Date, 4 - Binary, 5 - Reserved")
      iFieldsList.add("")
      iFieldsList.add("-----------------------------------------------------------------------")
                
      for x = 1 to iFieldDefs.count
        set iField = iFieldDefs.item(x)
        iFieldsList.add(FieldPad(iField.name) & IDS_SEPARATOR & iField.FieldType & IDS_SEPARATOR &_
        iField.FieldID & IDS_SEPARATOR & iField.Hidden & IDS_SEPARATOR & iField.ReadOnly) 
      next
      
      dim iFilePath
      iFilePath = Utilities.GetDataDirectory & "ADV_FieldDefs.txt"
      
      iFieldsList.SaveToFile(iFilePath)
      
      call msgbox("Field Definitions have been saved.  The text file will now be opened." & vbcrlf & iFilePath, vbInformation, IDS_CAPTION)
      Utilities.OpenDocument(iFilePath)
      
      set iFieldDefs = nothing
      set iFieldsList = nothing
      set iAddressBook = nothing
        
    End Sub
    
    
    function FieldPad(aValue)
      
      FieldPad = aValue
      
      x = len(FieldPad)
      if x < MAX_PAD then
        FieldPad = FieldPad & string(MAX_PAD - x," ")   
      end if   
      
    end function
    
    
    ' Prepare the address book dialog
    function PrepareAddressBookDlg(aBookName)
      
      dim iDlg
      dim iBook
      dim iBookCtl
      
      PrepareAddressBookDlg = FALSE
      
      set iDlg = Utilities.NewControlBoxDialog
      with iDlg
        .Height = 330
        .Caption = IDS_CAPTION
        .Title = "Address Book Field Definitions"
        .Description = vbCrLf & "To extract the field definitions, select the appropriate address book from the list below" 
      end with
      
      
      ' Address books
      set iBookCtl = iDlg.AddComboBoxControl  
      with iBookCtl
        .Caption = "Select an address book"
        for Each iBook in GroupWise.AddressBooks
          .Items.Add(iBook.Name)
        next  
        .Sorted = TRUE      
        .ItemIndex = 0    
      end with  
      
      if (iDlg.execute = btn2) then
        exit function
      end if
      
      aBookName = iBookCtl.Text 
      if (len(aBookName) > 0) then
        PrepareAddressBookDlg = TRUE 
      end if
      
      set iDlg = nothing
      set iBookCtl = nothing
      
    end function