Question

I try to loop through all ViewEntries in a view. After looping to some documents I get the error message "Object variable not set" when I want to set the "docOrder" document.

Debugging of the code shows that there are deletion stubs of documents in the ViewNavigator (no idea why?). When a deletion stub is in place the error message appears.

Here a code snippet of the LS-Script Agent:

 Call vwDelete.Refresh()
 vwDelete.AutoUpdate = False
 Set navOrders = vwDelete.createViewNav()
 Set veOrder = navOrders.getFirstDocument()

 While Not veOrder Is Nothing
    Set docOrder = veOrder.Document
        //do something
    Set veOrder = navOrders.getNextDocument(veOrder)
 Wend

I know I can use an If-Statement to check if the "document is nothing" but I'm curious why there are deletion stubs in ViewNavigator. It is an index problem? Any ideas?

Was it helpful?

Solution

From the documentation for the NotesViewEntry class

If a document is deleted after a ViewEntryCollection containing that document is created, the result of navigating to the deleted document will be a ViewEntry that can be used to navigate to the next entry, but nothing more. All of the properties or methods on this type of ViewEntry, except IsValid, will return an error. If you are sure that none of the documents in a ViewEntryCollection have been deleted, you don't need to check this property; otherwise, it should be checked.

You don't want to check against is nothing. You want to check if vOrder.isValid().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top