I am calling a Java agent using Formula code:
@Command([RunAgent]; "My Agent");
The agent runs and reads its parameters correctly. Some documents might change while the agent is still running. The agent doesn't see the changes and keeps reading the old values. To be concrete, the processing might be cancelled, so I am trying to tell my agent to stop. I am doing this by changing the value in a document I dedicated for passing arguments to the agent:
Call doc.ReplaceItemValue("Pause","True")
Call doc.Save(True, False)
This is what the agent does:
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
'Reload the document with the parameters
paramDoc = db.getDocumentByID(paramDoc.getNoteID());
But the agent only sees the default values. It seems to have an image of the database as it was at the time of calling it.
Any clue as to how to inform the agent about the new values or pausing/cancelling its thread?
Look at the Refresh method of the NotesDocument class. You need to call that before you check the value in your agent, to get any updated values.