/ Forums / Advansys Formativ / Creating Solutions with Formativ / Cache System Address Book entries to local file

  • Creator
    Topic
  • #4462
    Support 3
    Participant

      Accessing every entries from the System Address book can be very slow given a sufficiently large number of entries. Other factors may also affect access times, including network infrastructure, loadings, etc. Address Book access can also become slower as more entries are read from the server.

      If your solution need to access entries regularly then you can consider to cache entries to local file, perhaps once per day and retrieve from the cache file. You can also consider to save the cache file to Formativ temp folder, the contents of the temp directory are cleared on GroupWise startup and shutdown, so the cache file available for the GroupWise session. See the Formativ Language guide for more information.

      The sample code below check the cache file “system-ab-entries.txt” exists in Formativ temp folder, if the file exists then load entries to string list. If the file not exists then read System Address Book entries and add email address to the string list and save the file to temp folder.


      Sub Main(Client, GWEvent)

      dim oCacheEntries

      cacheFilePath = utilities.TempFiles & "system-ab-entries.txt"
      set oCacheEntries = Utilities.StringList()

      if FileExists(cacheFilePath) then
      oCacheEntries.LoadFromFile(cacheFilePath)
      else
      ReadEntries(oCacheEntries)
      oCacheEntries.SaveToFile(cacheFilePath)
      end if

      msgbox oCacheEntries.count

      set oCacheEntries = nothing

      End Sub


      ' Read System address book entries and add email address to stringlist
      sub ReadEntries(byref oCacheEntries)

      dim oAbEntry
      dim oAddressBook

      set oAddressBook = GroupWise.account.AddressBooks.item("GroupWise System Address Book")

      if oAddressBook is nothing then
      exit sub
      end if

      for each oAbEntry in oAddressBook.AddressBookEntries
      oCacheEntries.add(oAbEntry.EmailAddress)
      next

      set oAddressBook = nothing
      set oAbEntry = nothing

      end sub

      Regards,

      Advansys Support

    • You must be logged in to reply to this topic.