Updates the general fields (phone, adress extra) in the Notes Address Book from
a Human Resource DB or any other DB.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim s As New NotesSession
Dim coll As NotesDocumentCollection
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim Item As NotesItem
Dim compare As NotesItem
Dim db As NotesDatabase
Dim db2 As NotesDatabase 'Current database
(HR)
Dim doc As NotesDocument
Dim doc2 As NotesDocument 'Current Form
Dim dateTime As New NotesDateTime( "" )
Set db2 = s.CurrentDatabase 'To Define The Server
Set db = New NotesDatabase ("server","names.nsf") 'Address Book on
server
'Set db = New NotesDatabase ("","testnames.nsf") local Adress
book
Set uidoc=workspace.CurrentDocument
Set doc2=uidoc.Document
sFirstName$ = doc2.FirstName(0)
sLastName$ = doc2.LastName(0)
'sStatus$ = doc2.Status(0)
If doc2.Status(0)<>"Active" Then
Exit Sub
End If
selection$ = "@If(Form = ""Person"" & FullName=""" + sFirstName$ & " " &
sLastName$ +""")"
Set coll = db.Search( selection$, dateTime, 1 )
Set doc = coll.GetFirstDocument
If (doc Is Nothing ) Then
Messagebox "Employee does not exist in Address Book !!!!"
Exit
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.
End If
'Updates Parameters from HR to the NAB:
' Group -> Dep.
' Manager -> Manager
' Job Title -> Job Title
' Location -> Location
Set item = doc2.GetFirstItem( "Group" )
Set compare = doc.GetFirstItem("Department")
If Not item.Contains( catagory ) Then
doc.Department=doc2.Group
Call doc.save(True,False)
End If
Set item = doc2.GetFirstItem( "JobTitle" )
Set compare = doc.GetFirstItem("JobTitle")
If Not item.Contains( catagory ) Then
doc.JobTitle=doc2.JobTitle
Call doc.save(True,False)
End If
Set item = doc2.GetFirstItem( "Manager" )
Set compare = doc.GetFirstItem("Manager")
If Not item.Contains( catagory ) Then
doc.Manager=doc2.Manager
Call doc.save(True,False)
End If
Set item = doc2.GetFirstItem( "Location" )
Set compare = doc.GetFirstItem("Location")
If Not item.Contains( catagory ) Then
doc.Location=doc2.Location
Call doc.save(True,False)
End If
End Sub
This was first published in November 2000