代码之家  ›  专栏  ›  技术社区  ›  AHH

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

  •  2
  • AHH  · 技术社区  · 10 年前

    我从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 回复  |  直到 10 年前
        1
  •  4
  •   Knut Herrmann    10 年前

    你必须 拯救 Java代码中的文档 重新读取 调用代理后,在LotusScript中显示您的文档。

    它更容易使用 an In-Memory Document 尽管:

    Lotus脚本

    MyAgent.RunWithDocumentContext(doc, doc.NoteID)
    

    Java语言

    Document doc = agentContext.getDocumentContext()
    
        2
  •  1
  •   nempoBu4    10 年前

    如果出于某种原因,您无法使用 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)