Hello,
I am running following agent which will remove duplicate docs from a view.
I am facing following problem.
If duplicate docs are more than 2 in a view, then i get an error “Object varibale not set”.
When I debug the code, Debuger shows an error on line " Call doc.Remove(True) ".
It works fine if there are 2 docs for the same reqnumber in a view, but if there are more than 2 docs it gives an error. can any one guide me what could be the problem.
Sub Initialize
Dim ns As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim view As NotesView
Dim doc As NotesDocument
Set db = ns.CurrentDatabase
Set view = db.GetView(“DUP”)
Set doc = view.GetFirstDocument
While Not ( doc Is Nothing )
reqnum = doc.OBSRequestNumber(0)
Set NextDoc = view.GetNextDocument(doc)
Call DeleteDuplicateDocs ( Cstr(reqnum), db, doc )
Set Doc = NextDoc
Wend
End Sub
Function DeleteDuplicateDocs ( reqnum As String,
db As notesdatabase, doc As NotesDocument )
Dim j As Integer
Dim view As NotesView
Set view = db.GetView(“Duplicate\Latest Modified”)
j = view.FTSearch( reqnum , 0 )
If j > 1 Then
count = j - 1
For i = 1 To count
Call doc.Remove(True)
Next
End If
End Function