/ Forums / Advansys Formativ / Creating Solutions with Formativ / I’d like to uppdate addresses from a file into a personal address book.

  • Creator
    Topic
  • #4344
    dgerisch
    Participant

      Hello,

      I have a need to update a personal address book from a file for a number of users. I already have an applet that goes through each PAB entry, deletes it (until the whole address book is empty), and then loads a whole list of addresses from a file. This applet uses AddressBook.AddContact(displayname)

      Is there a similar AddressBook.UpdateContact(displayname) function?

      What I’d like to do is leave alone the new entries the users have added themselves. If an entry exists in my file, AND in the PAB, then I’d like to replace the existing entry in the PAB with the entry from the file. I’m having trouble figuring out how to iterate through the PAB and replace existing entries. I don’t think I can delete and add, as that would get weird during “For each AddressBookEntry in AddressBook” ….

      If you can point me in the direction of some sample code, that would be great. Thanks!

    • Author
      Replies
    • #7869
      Support 3
      Participant

        Please see the AddressBookEntry object in the Object API for the available properties of an address book entry. You need to iterate through the fields collection to access available fields (i.e. comments, address, personal address, etc).

        The sample code below update the email address and comments of first entry in the address book.

          
          dim oField
          dim oAddressBook
        
          set oAddressBook = nothing
          set oAddressBook = groupwise.account.addressbooks.item("Test Book")
        
          set oEntry = oAddressBook.AddressBookEntries.item(1)
        
          ' Before update
          msgbox oEntry.displayname & vbcrlf & oEntry.emailaddress
        
          oEntry.emailaddress = "test@hotmail.com"
        
          ' After update
          msgbox oEntry.displayname & vbcrlf & oEntry.emailaddress
        
        
          ' Fields collection
          for each oField in oEntry.fields
            if (lcase(oField.name) = "comments") then
              oField.value = "Updated comments1"
            end if
          next
        
          set oField = nothing
          set oAddressBook = nothing
        

        You can also view the “Formativ Developers Guide” for some sample code.

        Regards,
        Advansys Support

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