Subject: RE: Compare .xls file against notes database view
I have LS code where I import an excel sheet, than compare the records in the imported view to the view of another Lotus view (the Directory)- it logs documents in the imported view that aren’t in the directory- but, if you don’t write LS- that isn’t helpful- so, exporting the LS to excel would seem like the easier thing to do.
But the LS code is below - we have been bought by a large company and we are trying to normalize data that has not been kept in any one place (frustrating to me as an employee- like, what is that sales person’s phone #- oh, that is on this piece of paper over here…) now it is all in the Directory. Also, obviously the imported excel spreadsheet has the “correct” values for fields in the NAB- so, I just over write them.
Dim s As New NotesSession
Dim db As NotesDatabase
Dim LookupDB As New NotesDatabase( "Excalibur", "Apps\IT\DRSOutlookImport.nsf" )
Set db = s.CurrentDatabase
Dim SRSStaff As NotesView
Set SRSStaff = db.GetView("SRSUsers")
Dim LookupStaff As NotesView
Set LookupStaff = LookupDB.GetView("ImportView")
Dim Doc As notesdocument
Dim LookupDoc As notesdocument
'Set up items for replacing or updating
Dim JobTitle As NotesItem
Dim Department As NotesItem
Dim Location As NotesItem
Dim OfficeStreetAddress As NotesItem
Dim OfficeCity As NotesItem
Dim OfficeState As NotesItem
Dim OfficeZip As NotesItem
Dim EmployeeID As NotesItem
Dim OfficePhoneNumber As NotesItem
Dim CellPhoneNumber As NotesItem
Dim StreetAddress As NotesItem
Dim Comment As NotesItem
’ Dim City As NotesItem
’ Dim State As NotesItem
’ Dim Zip As NotesItem
Dim Phone As Notesitem
Dim CNName As String
Set LookUpDoc = LookUpStaff.GetFirstDocument
Do Until LookUpDoc Is Nothing
Set Doc = SRSStaff.GetDocumentByKey(LookUpDoc.CommonName(0))
Print "Working on " & lookupDoc.CommonName(0)
If Not Doc Is Nothing Then
' start process of iffing and setting
Call doc.ReplaceItemValue("JobTitle",LookupDoc.JobTitle(0))
Call doc.ReplaceItemValue("Department",LookupDoc.Department(0))
Call Doc.ReplaceItemValue("Manager",LookupDoc.Manager(0))
Call doc.ReplaceItemValue("OfficePhoneNumber",LookupDoc.OfficePhoneNumber(0))
Call doc.ReplaceItemValue("OfficeFaxPhoneNumber",LookupDoc.OfficeFaxPhoneNumber(0))
Call doc.ReplaceItemValue("CellPhoneNumber",lookupDoc.CellPhoneNumber(0))
Call doc.ReplaceItemValue("StreetAddress",LookupDoc.StreetAddress(0))
Call doc.ReplaceItemValue("City",LookupDoc.City(0))
Call doc.ReplaceItemValue("State",LookupDoc.State(0))
Call doc.ReplaceItemValue("Zip",LookupDoc.Zip(0))
Call doc.ReplaceItemValue("PhoneNumber",LookupDoc.PhoneNumber(0))
Call doc.ReplaceItemValue("DRSComEmail",LookupDoc.DRSComEmailAddress(0))
LookupEmployeeNumber = LookupDoc.employeeID(0)
Call Doc.ReplaceItemValue("EmployeeID",LookupEmployeeNumber)
’ Call doc.ReplaceItemValue(“Comment”,LookupDoc.FullLegalName(0))
doc.FullLegalName = LookupDoc.FullLegalName(0)
Call doc.Save(True,True)
Print "Done Working on " & Lookupdoc.CommonName(0)
Goto GetNextDoc
Else
Print "Failed at " & lookupdoc.commonname(0)
Dim logdoc As NotesDocument
Set logdoc = LookupDB.CreateDocument
logdoc.form = "NABImportLog"
'For some reason this is erroring out
LogDoc.Logdate = Now
logdoc.CommonName = LookupDoc.CommonName(0)
LogDoc.FirstName = LookupDoc.LegalFirstName(0)
LogDoc.MiddleInitial = LookupDoc.MI(0)
LogDoc.LastName = LookupDoc.LegalLastName(0)
Print "Logged " & LookupDoc.CommonName(0)
Dim AuthorsItem As New NotesItem(LogDoc,"Author",s.UserName,Authors)
Call Logdoc.Save(True,True)
End If
Goto GetNextDoc
GetNextDoc:
Set LookUpDoc = LookupStaff.GetNextDocument(LookUpDoc)
Loop
Exit Sub