• Creator
  • #3950

    I’m currently looking at FormativCentral but have 2 questions regarding accessing fields assigned to an address book entry.

    1) do you have an API that allows a list of all possible fields to be returned, or a list of defined fields against a single address book entry.

    2) (the harder question) are you able to return the “Last Reference” and “Reference Count” fields found in the Frequent Contact address book in some way?

    The reason for these questions is that GW does not document the names that such values can be accessed by and many of the GW names include spaces (so are not correct). Also as far as I can tell there seems to be a problem with accessing “Last Reference” and “Reference Count” and it would be nice to have proof before I report the issue to Novell.


  • Author
  • #6687
    Support 1a

    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
    ' 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")
      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) 
      dim iFilePath
      iFilePath = Utilities.GetDataDirectory & "ADV_FieldDefs.txt"
      call msgbox("Field Definitions have been saved.  The text file will now be opened." & vbcrlf & iFilePath, vbInformation, IDS_CAPTION)
      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
        .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

    Thanks for the quick reply (and example code).

    My question for you is about the AddressBook object. The available examples such as in the programmers guide shows a number of properties that relate to the field definitions, but does not detail how the names are created. For example it looks as if you remove all spaces so “First Name” becomes “FirstName”, but how do you decide that “Office Phone number” should become just “OfficePhone”.

    Also with the info you have given me, it looks as if Novell has a problem with the address book printing tool as it can’t handle “Last Reference” and “Reference Count” my guess is that its due to the field type being mumeric rather than string.

    Thanks again



    Ok, I’ve now got a better understanding of the problem.

    Your addressbook object is hardcoded so that it supports “all standard fields” only. I would query the fact that the reference fields are not included as “standard” as they would be rather useful when writing scrips to report on address books.

    Also do you have any example code for accessing the other fields, via the field name or Field ID.

    Thanks again


    Support 1a

    There are two techniques you can use to access address book information.

    1) The standard GroupWise.Account object, which provides lower-level, complete, yet more difficult to use access, or

    2) the GroupWise.AddressBooks object, which provides higher-level, yet simpler access.

    The technique you use will ultimately depend on the problem you are trying to solve.

    Option 1) uses the native GroupWise Object API to reference the address book. You need to use the FieldDef approach shown in the example to access field data.

    Option 2) wraps the Object API in a simple object model. Only basic fields are exposed by hard coded property name (such as FirstName). The names of the properties were chosen as simple representations of the names. The reference fields were not encapsulated, as they were not considered to be widely used. Using this technique you are still able to access the reference fields, or any other fields supported by the address book via the AddressBookEntry.Object property. This gives you access to the native Object API AddressBookEntry object. Likewise, the wrapped AddressBook object also exposes an Object property. Using the .Object properties, you are able to access any Field in a book using a variation on the technique shown in the example above.

    There are several examples of address book access available from AppletCentral on CoolSolutions. There are also a couple of examples in the examples pack you can download from our web site.

    I hope this helps.

    Advansys Support

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.