Manage Learn to apply best practices and optimize your operations.

Get Person Document from NAMES.NSF with CGI Remote User

At times it is necessary to get the details of the Domino "cgi - Remote_User" person Document in NAMES.NSF. In my case, I needed to get a value from the comments field (which was actually not a comment but a key value to get the person document in our custom Address Book).

I thought it was not a good idea to change the design of the Public Address Book(NAMES.NSF) because of the upgrades and such that this NSF goes through (e.g. the design changes could be lost).

So, I wrote something that would get the cgi varaible, Remote_User, and from that get the person document in NAMES.NSF. From there you can get the details in any of the fields in that person document. i.e. Phone Number, Email address, Comments.

Randy McDougall

Dim session as New NotesSession
Dim cgidoc as NotesDocument
Dim remote_user as String

Set cgidoc = session.DocumentContext

remote_user = cgidoc.Remote_User(0)

' This function is used to get the Person doc from names.nsf
' Randy McDougall Nov. 19, 1998


Dim db As New NotesDatabase ("", "names.nsf")

Dim view As NotesView

Dim IDdoc As NotesDocument

' Create a name string that will match a lookup in names.nsf people view

Dim positionOfChar As Long
Dim lengthOfString As Long

lengthOfString& = Len(remote_user)

theSpace = " "
positionOfChar& = Instr(1, remote_user, theSpace)

Dim holder As Long
holder = LengthOfString - positionOfChar

Dim FirstName As String
FirstName$ = Left$(remote_user, positionOfChar - 1)

Dim LastName As String
LastName$ = Right$(remote_user, holder )

nameString = LastName + " , " + FirstName


Set view = db.GetView("People")

Set IDdoc = view.GetDocumentByKey(nameString)

'Here you can get any value you like
'I needed an id(key value) from the comments field
Dim ID As String
ID = IDdoc.comment(0)

Dig Deeper on Domino Resources - Part 6



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury