I am passing parameters to a Java agent from Lotus Script like this:
Set db = session.CurrentDatabase
Set doc = db.CreateDocument
Set uiDoc = workspace.CurrentDocument
Call doc.AppendItemValue("fileName", "SomeString" )
Call doc.Save(True, False)
Set MyAgent = db.GetAgent("AgentName")
Call MyAgent.Run(doc.NoteID)
Set session = New NotesSession
Set db = session.CurrentDatabase
result = doc.GetItemValue("Result")(0)
The agent says the following in Java:
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Agent agent = agentContext.getCurrentAgent();
Database db = agentContext.getCurrentDatabase();
Document doc = db.getDocumentByID(agent.getParameterDocID());
String fileName = doc.getItemValueString("fileName");
doc.appendItemValue("Result","MyResult");
doc.save();
The agent is doing his job correctly. I checked the parameter document and it indeed contains the results from the agent. However, my form is not able to read the Result parameter.
You have to save the doc in your Java code and to re-read your doc in LotusScript after calling your agent.
It is easier to use an In-Memory Document though:
LotusScript
MyAgent.RunWithDocumentContext(doc, doc.NoteID)
Java
Document doc = agentContext.getDocumentContext()