I am doing a search then looping through the results. This is causing my code to lock up and worse, it is locking up that database from any further use. Even after the browser is closed. It seems this “lockup” is cleared after a period of time of course until I try my code again. I am going to change the way I do this particular task but I was curious as to what is causing this lockup.
var collection = database.search("Form = 'Request01' & Status='Approved'");
if (collection.getCount() == 0)
{
getComponent("panel1").setRendered(false);
getComponent("panel2").setRendered(true);
getComponent("panel4").setRendered(true);
return;
}
dBar.info("Approved Requests Found= " + collection.getCount());
var item:NotesItem = document1.replaceItemValue("DocIds","AAAA");
var doc:NotesDocument = collection.getFirstDocument();
while (doc != null)
{
try
{
var tmpDoc = collection.getNextDocument(doc);
item.appendToTextList(doc.getNoteID());
dBar.info("Processing document: " + doc.getNoteID() )
doc.recycle();
doc = tmpDoc;
}
catch(e)
{
dBar.error(e.message);
}
}
document1.save();
The following line…
… returns void, your variable item is undefined. The next operation with this
throws an error and ends up always in your catch-Block. Then, the next document is never fetched, you have an infinite loop.
EDIT:
The replaceItemValue method normally returns the NotesItem, but not for a NotesXspDocument!