Validate a name against the NAB
The checkNAB function is a LotusScript function that compares a name with all the public NABs.
The checkNAB function is a LotusScript function that compares a name with all the public NABs. The name can be a person, group or mail-in db name. The function returns true if a name is found and false when a name isn't found.
I've found this to be a useful when I've asked the user to enter a name. The function ensures that the name entered is a valid Lotus Notes name within our environment.
Sub Click(Source As Button) Const NAME_OF_PERSON = "Joe Mamma" Const NAME_OF_PERSON2 = "Curtis R. Stull" Msgbox (NAME_OF_PERSON & " = " & CheckNAB( NAME_OF_PERSON ) & " AND "
& NAME_OF_PERSON2 & " = " & CheckNAB( NAME_OF_PERSON2 ) ) End Sub Function CheckNAB(strperson As String) As Integer Dim s As New NotesSession Dim view As NotesView Dim doc As NotesDocument books = s.AddressBooks Forall db In books If db.IsPublicAddressBook Then Call db.Open( "", "" ) If db.IsOpen Then Set view = db.GetView ( "($VIMPeopleAndGroups)" ) If Not view Is Nothing Then Set doc = view.GetDocumentByKey ( strperson ) ' if person is found then return true,
otherwise goto the next address book If Not doc Is Nothing Then CheckNAB = True Exit Function End If End If End If End If End Forall CheckNAB = False End Function