Retrieving changes made by a Java Agent on a document

我与影子孤独终老i 提交于 2019-12-02 05:00:32

问题


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.


回答1:


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()



回答2:


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)


来源:https://stackoverflow.com/questions/24658499/retrieving-changes-made-by-a-java-agent-on-a-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!