The document is not in view($inbox)

Dear All,

I have an agent, works after selecting an email and run the agent which will perform some operation. Some times,An error message is thrown [The document is not in view($inbox)] .

Can anyone explain the cause and precaution code?

Subject: Without any specific code, I am guessing you are probably calling a NotesDocument.Save.

Many questions such as this is helpful if you provide code of your problems.

Typically, the help tells you to use NotesView.GetNextDocument(NotesDocument) to iterate through your view. However people get the errors that you describe when they take that iteration “as-is”, edit the document, and call NotesDocument.Save.

Once that happens, the view immediately looses a reference to that document (because something may change in it that may need to verify against the view selection formula)–it has to wait until the view refresh task can check the View Selection formula to verify / update “new and edited” documents to see if it belongs, then sort it accordingly–all behind the scene. So, after you save a document, and you try NotesView.GetNextDocument, that document is no longer a part of that view for the brief moment in LotusScript.

The best technique is to use another temporary NotesDocument to hold the next document before calling save. Such as the following:

set VIEW = …

dim doc as notesdocument

dim docNext as notesdocument

set doc=VIEW.getfirstdocument

do while not (doc is nothing)

set docNext=VIEW.getnextdocument(doc)

call doc.save(true, true)

set doc = docNext

loop

Hope that helps, if it does not, please post the code you are having problems with.

-Kyle Huang