Search code examples
xpageslotus-noteslotus-dominoxpages-ssjsssjs

Xpages - Exception occurred calling method NotesView.getNextDocument(lotus.domino.local.Document) null


I'm getting the above error. Is there a way I can check if next document is null? Below is my code:

var vec:NotesView = database.getView("QueryNotes");
var queryColl:NotesDocumentCollection =   vec.getAllDocumentsByKey(ProjectUNID,true);
if(queryColl.getCount() > 0){
var queryDoc1:NotesDocument = queryColl.getFirstDocument();
while (queryDoc1 != null) {
    if(!queryDoc1.hasItem("QueryEndDate")){
        queryDoc1.appendItemValue("QueryEndDate", session.createDateTime(@Now()));

        var tmpdoc = vec.getNextDocument(queryDoc1); //error when next is null, or does not exist
        queryDoc1.recycle();
        queryDoc1 = tmpdoc;
      }
   }
}

There should be a way of checking, a similar question on stackoverflow did not answer the question.

Looking forward to your response.


Solution

  • You are calling getNextDocument() on the vec variable (which is a view object and doesn't have that method). You should use the queryColl variable instead.