Retrieve the nab department of the user

I’m new to the notes designer but not new to programming in general … I just can’t seem to find a way to retrieve the department from the domino public nab for the user that is logged in. This seems like it should be easy to do but I’m not having any luck. Any help would be greatly appreciated.

Subject: retrieve the nab department of the user

I assume you want to do it with lotusscript

Dim sess As New notessession

'store the common name of the current user as string

Dim cn As String

cn = sess.CommonUserName

'get the first and last name from the common name

Dim firstname As String

firstname = Strtoken(cn," ", 1)

Dim lastname As String

lastname = Strtoken(cn," ", 2)

'joining the first and last name

Dim nam As String

nam = lastname & " , " & firstname

'get your address book, you can also use the getaddressbooks property here as well

Dim nab As notesdatabase

Set nab = sess.GetDatabase(“server name”, “filename”)

'getting the people view from the pnab, I assume your address book has a view called People with first sorted column showing last name , first name

Dim view As NotesView

Set view = nab.GetView(“People”)

'getting the user’s person document

Dim perdoc As NotesDocument

Set perdoc = view.GetDocumentByKey(nam)

Msgbox perdoc.Department(0)

Subject: RE: retrieve the nab department of the user

Please use Namelookup rather than database calls. Namelookup protects you from various directory deployment situations (secondary directories, central directory architecture, etc.) that may be impractical to address with database calls. The reasons are outlined in “Building Directory Friendly Applications” referred to in the “Domino Directory FAQ” (google it)

See @NameLookup in “Programming Guide, Volume 1: Overview and Formula Language”

http://www-12.lotus.com/ldd/doc/uafiles.nsf/docs/DESIGNER70/$File/prog1.pdf