Q

Accessing location documents

How do you access the CURRENT location document from LotusScript? I am getting ready to decommission a mail server, and there is a group of users who no longer use Notes for email, but still use it to access applications. Since these users do not open the mailfile, I want to give them a stub database that they can be directed to in order to have their location document updated so that their Notes client does not try to check the non-existent server for mail.

How do you access the CURRENT location document from LotusScript? I am getting ready to decommission a mail server, and there is a group of users who no longer use Notes for email, but still use it to access applications. Since these users do not open the mailfile, I want to give them a stub database that they can be directed to in order to have their location document updated so that their Notes client does not try to check the non-existent server for mail.
This is one of those cases where it is handy that all parts of the Notes infrastructure share the same technology. The name of the current location is stored in the Notes.ini file and is available through the environment functions. The location documents are stored in the user's personal address book, which is an ordinary Notes database very similar in design to the public address book. The personal address book is nearly always "names.nsf" on the local machine, but the code below will find it no matter where it is. Since I have examined the design of the personal NAB in the past, I know just where to look to find the location documents.

This code will raise a user defined error 4101 if any problem occurs. If you don't catch it, the user will see

it. To catch it, precede the call with an "ON ERROR 4101 goto MyHandler". In the handler, the error message can be accessed through $Error. You may want to collect error messages for analysis in a log or simply by emailing them somewhere. Due to the nature of this code, I'm reporting every error that could conceivably occur that I can think of.

Public Function GetCurrentLocation As NotesDocument

  • Dim session As New notessession
  • Dim books As Variant
  • books =session.AddressBooks
  • Forall b In books ' get users public address book
    • If Not b.IsPublicAddressBook Then
      • Call b.open("","")
      • If b.isOpen Then
        • Dim locations As NotesView
        • Set locations=b.GetView("Locations")
        • If Not locations Is Nothing Then
          • Dim key As String
          • key=session.GetEnvironmentString("Location",True)
          • If key<>"" Then
            • Dim index As Integer
            • index=Instr(key,",")
            • If index>0 Then key=Left(key,index-1)
            • Dim location As NotesDocument
            • Set location=locations.GetDocumentByKey(key,True)
            • If Not location Is Nothing Then
              • Set GetCurrentLocation=location
              • Exit Function
            • Else
              • Error 4101, {Current location document not found.}
            • End If
          • Else
            • Error 4101, {Unable to look up current location.}
        • End If
      • Else
        • Error 4101, {Personal name & address book does not contain a "Locations" view.}
      • End If
    • Else
      • Error 4101, "Unable to open personal name & address book"
    • End If
  • End If
  • End Forall
  • Error 4101, "Unable to locate personal name & address book"
    • End Function
    This was first published in September 2006

    Dig deeper on LotusScript

    Have a question for an expert?

    Please add a title for your question

    Get answers from a TechTarget expert on whatever's puzzling you.

    You will be able to add details on the next page.

    0 comments

    Oldest 

    Forgot Password?

    No problem! Submit your e-mail address below. We'll send you an email containing your password.

    Your password has been sent to:

    SearchWinIT

    Search400

    • iSeries tutorials

      Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

    • V6R1 upgrade planning checklist

      When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

    • Connecting multiple iSeries systems through DDM

      Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

    SearchEnterpriseLinux

    SearchVirtualDataCentre.co.uk

    Close