2

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.

AHH
  • 981
  • 2
  • 10
  • 26

2 Answers2

4

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()
Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
1

If for some reason you cannot use RunWithDocumentContext (in earlier versions of Lotus Notes) then you need to reopen document:

Set db = session.CurrentDatabase
Set doc = db.CreateDocument

Call doc.AppendItemValue("fileName", "SomeString" )
Call doc.Save(True, False)

noteID$ = doc.NoteID

Set MyAgent = db.GetAgent("AgentName")
Call MyAgent.Run(noteID$)

'Delete document from memory.
Delete doc

'Get updated document.
Set doc = db.GetDocumentByID(noteID$)
result = doc.GetItemValue("Result")(0)
nempoBu4
  • 6,521
  • 8
  • 35
  • 40