Vijayakumar
Vijayakumar

Reputation: 85

Exception occurred calling method NotesDocumentCollection.putAllInFolder(string)

I am getting the following error while copying more than 17000 documents to a folder:

Exception occurred calling method NotesDocumentCollection.putAllInFolder(string)

This is my code:

docColl = database.search(formula);
getComponent("TempName").setValue(docColl.getCount());
docColl.putAllInFolder("f_Statistics");

If I move less than 17000 documents, it works. There is nothing to with no of documents in the view.

How can I solve this problem?

Upvotes: 0

Views: 696

Answers (2)

Richard Schwartz
Richard Schwartz

Reputation: 14628

Perhaps you can use a loop and a try... catch to handle the error. I'm not sure about the exact syntax you would need for xpages, but could be something like this:

docColl = database.search(formula);
exceptionCaught = true;  // little white lie
while(exceptionCaught = true);
{

  getComponent("TempName").setValue(docColl.getCount());
  exceptionCaught = false;
  try
  {
    docColl.putAllInFolder("f_Statistics");
  }
  catch (Exception e)
  {  // It blew up; assume that this means there were too many docs
     View folder = db.getView("f_Statistics");
     docColl.Subtract(folder.getAllEntries();
     exceptionCaught = true;
  }
}

Yes, it's a hack.

And no... the above is not tested, or even syntax checked. I'm just throwing out the idea.

If you try this, I strongly recommend that you do some additional checking to make sure that the cause of the exception really is the number of docs, because if any other exception occurs, the above code will most likely be an infinite loop!

Upvotes: 1

Karl-Henry Martinsson
Karl-Henry Martinsson

Reputation: 2795

How can I solve this problem?

Copy fewer documents? Whty not split it up into multiple moves if you are having problems when the number of documents exceede a certain number?

Upvotes: 1

Related Questions