Probelm in for document handle in a view

Hi All,

I have one schedule agent which run once a day and this agent fetch every document from this specified view and then check document cancellation date and compare to today date if this small then simple archive all document under this refno but some time it is skip some document mycode is like this below…

Set CXLview=db.GetView(“(CxlTours)”)

Call CXLview.refresh

Set CurrDoc = CXLview.getFirstDocument	

----My all code here

Set CurrDoc = CXLview.GetNextDocument(CurrDoc) ’ next tour

While Not CurrDoc Is Nothing

So can any one suggest me what can i implement here so that it check all document in this view not skip any document.

Subject: Probelm in for document handle in a view

First of all, you need to fix your code.Both your code and GetNextDocument should be inside the while-loop. It is also better to use a Do-Until loop.

Set CXLview=db.GetView(“(CxlTours)”)

Call CXLview.refresh

Set CurrDoc = CXLview.getFirstDocument

Do Until CurrDoc Is Nothing

----My all code here

Set CurrDoc = CXLview.GetNextDocument(CurrDoc) ’ next tour

Loop

If your code is modifying the document(s) in a way so it will affect the visibility in the view, you need to take this in consideration. There are several ways to do that, depending on what your code is doing.

You can turn off view auto updates through view.AutoUpdate = false.

Another way I handle it is that I first build a list of the documents to process, then after all documents have been identified, the list is processed.

This is especially useful when you need to delete documents.

The code could look like this:

Dim docList List As NotesDocument

Set view=db.GetView(“(LookupView)”)

Call view.refresh

Set doc = view.GetFirstDocument

Do Until doc Is Nothing

Set docList(doc.UniversalID) = doc

Set doc = view.GetNextDocument(doc)

Loop

ForAll d in docList

Call d.Remove(True) ’ Or your code to act on document

End ForAll