AHH
AHH

Reputation: 1083

Java Agent not receiving updates after launching

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?

Upvotes: 0

Views: 167

Answers (2)

Normunds Kalnberzins
Normunds Kalnberzins

Reputation: 1245

In order to read the current value (discard cache) use:

noteid = paramDoc.getNoteID()
Delete paramDoc
paramDoc = db.getDocumentByID(noteid);

well, this was for LotusScript - you are using Java in agent. So I guess it will be (edited to include clarification as proposed by nempoBu4):

String noteid = paramDoc.getNoteID();
paramDoc.recycle();
paramDoc = db.getDocumentByID(noteid);
//Check the new value

Upvotes: 2

Karl-Henry Martinsson
Karl-Henry Martinsson

Reputation: 2795

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.

Upvotes: 0

Related Questions