0

How do I do a recycle for GetNextDocument or GetNextCategory in a NotesViewNavigator? Neither takes an argument so you can't use the conventional method of using a temp variable to pre get the next document like you might in a view.

I suppose the solution would be to just use getNext with an argmenumnt but can GetNextDocument / GetNextCategory still be used?

The error I am getting is on line 20. Without the recycle the code runs fine. From what I understand recycle destroys the object so I can understand the reason for the error. My questition is if there is another way around this?

[TypeError] Exception occurred calling method NotesViewNavigator.getNextDocument() null occurs on line 20

 1: var viewName = "vwParticipantsProjectIDEquipmentIDUsername";  
 2: 
 3: 
 4: var v:NotesView = database.getView(viewName);
 5: var nav:NotesViewNavigator = v.createViewNavFromCategory(sessionScope.get("ExportProjectID"));
 6: 
 7: 
 8: var viewEnt:NotesViewEntry = nav.getFirstDocument();
 9: 
 10: while (viewEnt != null)
 11: {  
 12: 
 13:    if (viewEnt.isDocument())
 14:    {
 15:        
 16:        var doc:NotesDocument = viewEnt.getDocument();
 17:    }       
 18: 
 19:    viewEnt.recycle();
 20:    viewEnt = nav.getNextDocument();
 21: }
Bruce Stemplewski
  • 1,343
  • 1
  • 23
  • 66

2 Answers2

1

This is the pattern that I tend to use:

var documentEntry = nav.getFirstDocument();
while( documentEntry != null ){
  var nextDocumentEntry = nav.getNextDocument();
  // do stuff
  documentEntry.recycle();
  documentEntry = nextDocumentEntry;
}
Tommy Valand
  • 868
  • 6
  • 10
0

Why don't you try to apply the old pattern like this:

var viewName = "vwParticipantsProjectIDEquipmentIDUsername",
    v:NotesView = database.getView(viewName),
    nav:NotesViewNavigator = v.createViewNavFromCategory(sessionScope.get("ExportProjectID")),
    viewEnt:NotesViewEntry = nav.getFirstDocument(),
    tmp:NotesViewEntry;
while (viewEnt !== null)
{  
    if (viewEnt.isDocument())
    {
        var doc:NotesDocument = viewEnt.getDocument();
    }
    tmp = viewEnt;
    viewEnt = nav.getNextDocument();
    tmp.recycle();
}

I did not test it, but I guess that works...