检索Java代理对文档所做的更改

时间:2014-07-09 15:59:10

标签: lotus-notes lotus-domino lotusscript lotus

我将参数从Lotus Script传递给Java代理,如下所示:

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)

代理在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();

代理正在正确地完成他的工作。我检查了参数文档,它确实包含代理的结果。但是,我的表单无法读取Result参数。

2 个答案:

答案 0 :(得分:4)

在调用代理后,您必须保存您的Java代码中的文档,并重新阅读您的LotusScript文档。

虽然使用an In-Memory Document更容易:

的LotusScript

MyAgent.RunWithDocumentContext(doc, doc.NoteID)

Java

Document doc = agentContext.getDocumentContext()

答案 1 :(得分:1)

如果由于某种原因您无法使用RunWithDocumentContext(在早期版本的Lotus Notes中),则需要重新打开文档:

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)
相关问题