I have an error with my agent:Notes error: entry not found in index(forArchiver)
My code in LS
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim ProfileDoc As NotesDocument
Dim nextDateTime As NotesDateTime
Dim var As Integer
Set nextDateTime = New NotesDateTime( "Today" )
Set db = session.CurrentDatabase
Set ProfileDoc = db.GETPROFILEDOCUMENT("Setup Profile")
var = ProfileDoc.GetItemValue("ProfileArch")(0)
' Calcule ici le délai pour l'archivage.
Call nextDateTime.AdjustMonth(-var)
' Met le flag archiv à 1
Set view = db.GetView( "forArchiver" )
Set doc = view.GetFirstDocument
While Not ( doc Is Nothing )
If doc.GetItemValue("DateFin")(0) > nextDateTime.LSLocalTime Then
Call doc.ReplaceItemValue("archiv",1)
Call doc.Save(True, False)
End If
Set doc = view.GetNextDocument( doc )
Wend
End Sub
I have test and the error is produce by doc.ReplaceItemValue(“archiv”,1).
But this field exist in my document. It’s a field compute.
Subject: Notes error: entry not found in index
Are you sure that the code doc.ReplaceItemValue(“archiv”,1) is the problem? I think it might be that you have a selection formula in the view that uses the archiv field, that is, the document that you save disappears from the view, the error will be thrown at set doc = view.getNextDocument(doc), since the doc passed as argument no longer exists in the view. You have to do a doc = view.getFirstDocument() instead…
johan@kanngard.net
http://dev.kanngard.net
Subject: RE: Notes error: entry not found in index
Thanx.I understand my problem.
Subject: RE: Notes error: entry not found in index
You can also set AutoUpdate property of the view to False before executing the loop, in which case the orginal code need not be modified to get the first document everytime.
cheers !!
Ashish
Subject: RE: Notes error: entry not found in index
My problem is not resolve.How set AutoUpdate property of the view to False ?
Subject: RE: Notes error: entry not found in index
Add the statement after you get the handle to the view … i.e.
Set view = db.GetView( “forArchiver” )
view.AutoUpdate = False
cheers !!
Ashish
Subject: RE: Notes error: entry not found in index
ThxIt’s good.
Sylvain