How to pass the Document context in Xpages while calling an Agent?

橙三吉。 提交于 2019-12-08 21:10:33

agent.runWithDocumentContext(currentDocument.getDocument(true)). This will put all the new values inside the backend doc, so it works the same way as lotusscript does. Also, if you need to have the currentdocument computed with the notes form, set the 'computewithnotesform' property of the datasource to 'onload' or 'both'.

Since when there can be more then one document source on the xPage, I use ParameterDocID...

var id = document1.getDocument().getNoteID();
var agent = database.getAgent("MyAgent");
agent.run(id)

and in the agent...

Call GetDocument(agent.ParameterDocID)

...

Public Sub GetDocument(DocID As String)
On Error GoTo eh

Set Doc = Db.GetDocumentByID(DocID)

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