/ Forums / Advansys Formativ / Creating Solutions with Formativ / Filter in GroupWise Address Book for logged-in user

  • Creator
    Topic
  • #4019
    Anonymous

    I am trying to get the Full Name field for the logged-in user from the GroupWise Address book (and not through an LDAP query to e-directory). The whole thing crashes with syntax errors on my attempt to Find, no matter if I include or exclude the brackets. Anything obvious I’m doing wrong here?

    Sub Main(Client, GWEvent)
    dim oField
    dim oEntry
    dim oFieldObj
    dim oAddressBook

    set oAddressBook = GroupWise.Account.AddressBooks.Item(“Novell GroupWise Address Book”)

    UserId=Groupwise.EnvUserID()

    Set oEntry = oAddressBook.AddressBookEntries.Find(<EMailAddress> CONTAINS UserID)
    if oEntry is nothing then
    msgbox “oEntry is nothing. Quitting”
    exit sub
    end if

    msgbox “Name: ” & oEntry.DisplayName

    Set oFieldObj = oEntry.Fields
    Set FullName = oFiledObj.Item(23)

    End Sub

  • Author
    Replies
  • #6870
    Support 1
    Participant

    The filter string should be quoted, and your email address field syntax is incorrect. Correct usage is as follows:

      set oEntry = oAddressBook.AddressBookEntries.Find("(<E-Mail Address> CONTAINS """ & UserId & """)")

    The method Find returns a collection of address book entries. The code should read each address book entry from that collection. Correct usage is as follows:

      set oEntry = oEntries.Item(1)
      set oFieldObj = oEntry.Fields

    If we only want the full name of the logged-in user, then there is no need to use the address book, which is very inefficient. We can do so as follows:

      msgbox "Name: " & groupwise.account.owner.displayname & vbcrlf & _
             "Email: " & groupwise.account.owner.emailaddress

    I hope this helps.

    Advansys Support

    #6866
    rstarr
    Participant

    Thanks for the help. Setting the syntax to:
    set oEntry = oAddressBook.AddressBookEntries.Find(“(<E-Mail Address> CONTAINS “”” & UserId & “””)”)

    Results in the following error in running the applet:
    “Invalid procedure call or argument on [that line], column 0”

    If I try (which is more precisely what I want):
    set oEntry = oAddressBook.AddressBookEntries.Find(“(<E-Mail Address> BEGINSWITH “”” & UserId & “””)”)
    I get an error when running the applet:
    “Invalid operator for data type at [that line], column 0”

    Does either of these work on your end?

    I need the Full Name, e.g. John Q. Smith, and not the display name, e.g. John Smith (missing the middle initial), of the logged-in user. Full Name is not one of the 20 normal Novell GroupWise Address Book fields, thus I made it a Admin-Defined Field in GroupWise mapped to the e-directory Full Name field (thus the oFieldObj.Item(23) in my code). I don’t want to use LDAP to query e-directory for this field directly because doing so requires ActiveX, which is slow to respond and requires a per-user registration of ActiveX on Windows XP. Is there a better/another way to get at the Full Name?

    If I try:
    msgbox “Name: ” & groupwise.account.owner.fullname
    I get the error:
    “Object doesn’t support this property or method: ‘GroupWise.Account.owner.fullname’ at line 20, column 1”

    Very frustrating. Thanks for whatever help you can offer.

    #6868
    Support 1
    Participant

    I am not sure why you get the error ‘Invalid procedure call…’ That line of code works fine for us (GroupWise 6.5.1). What version of the GroupWise client are you using?

    Novell’s online documentation here notes the method AddressBookEntries.Find does not support the BEGINSWITH operator.

    The properties of Address object GroupWise.Account.Owner are fixed (see the API documentation). The Object API knows nothing about admin-defined fields, so you cannot retrieve your FullName property in this way.

    Below is a complete sample applet. Note that collections such as AddressBookEntries, Fields are 1-based (not zero-based, like VBScript arrays).

    --------------------------------------------------------------------------------
    ' Displays a dialog, listing every field in the first
    ' address book entry matching the logged-in user.
    sub Main(Client, GWEvent)
    
      dim iUserId
      dim iText
      dim oEntry
      dim oEntries
      dim oField
      dim oFields
      dim oAddressBook
    
      set oAddressBook = GroupWise.Account.AddressBooks.Item("Novell GroupWise Address Book")
    
      iUserId = Groupwise.EnvUserID()
    
      set oEntries = oAddressBook.AddressBookEntries.Find("(<E-Mail Address> CONTAINS """ & iUserId & """)")
      if oEntries is nothing then
        msgbox "oEntries is nothing. Quitting"
        exit sub
      end if
    
      set oEntry = oEntries.Item(1)
      set oFields = oEntry.Fields
    
      iText = ""
      for each oField in oFields
        iText = iText & "Name: " & oField.Name & ", Value: " & oField.Value & vbCrLf
      next
    
      msgbox iText
    
      set oField = nothing
      set oFields = nothing
      set oEntry = nothing
      set oEntries = nothing
      set oAddressBook = nothing
    
    end sub
    --------------------------------------------------------------------------------

    Advansys Support

    #6869
    Anonymous

    That worked great. Thanks. I had confused Entry and Entries in my code.

    #6867
    Support 1
    Participant

    Glad to be of service!

    Advansys Support

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