Compare documents in 2 databases
|
This LotusScript agent compares documents in 2 replicas of Address Books and shows what group documents are missing in each replica.
You can modify the agent to use values of fields instead of UniversalID to perform the comparision. You can also expand search to include all documents in database.
Sub Initialize
'Copyright Botstation (www.botstation.com)
Dim session As New NotesSession
Dim db1 As NotesDatabase
Dim db2 As NotesDatabase
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
'We use List data type for holding values. This is done to achieve faster performance when comparing values from 2 databases.
Dim db1list List As String 'List1
Dim db2list List As String 'List2
Set db1=New NotesDatabase("Server1", "names.nsf" )
Set db2=New NotesDatabase("Server2", "names.nsf" )
'Get a collection of documents
Set coll=db1.search(|Form="Group"|, Nothing, 0) 'db1.AllDocuments
Set doc=coll.getfirstdocument
While Not doc Is Nothing
'populate List1 with values from documents
db1list(doc.universalid)=doc.universalid
Set doc=coll.getnextdocument(doc)
x=x+1
Wend
'Get a collection of documents
Set coll=db2.search(|Form="Group"|, Nothing, 0) 'db2.AllDocuments
Set doc=coll.getfirstdocument
While Not doc Is Nothing
'populate List2 with values from documents
db2list(doc.universalid)=doc.universalid 'Cstr(doc.created)
Set doc=coll.getnextdocument(doc)
y=y+1
Wend
'Find out what documents are missing in db2 by coparing all values in List1 with values in List2
Forall v In db1list
If Not Iselement ( db2list ( Listtag(v) ) ) Then
Print Listtag(v)+" is missing in db2"
End If
End Forall
'Find out what documents are missing in db1 by coparing all values in List2 with values in List1
Forall v In db2list
If Not Iselement ( db1list ( Listtag(v) ) ) Then
Print Listtag(v)+" is missing in db1"
End If
End Forall
Print "Done"
End Sub
Example output from this agent:
|
|