This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Apr 27, 2011, 3:31 PM
4 Posts
topic has been resolvedResolved

Document Context Document is empty in agent when called with runWithDocumentContext from XPage

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: runWithDocumentContext xpages SSJS
  • Replies: 2
I was thinking the new runWithDocumentContext(doc) call in 8.5.2 was going to allow the sending of an unsaved xpage document, or associated in memory NotesDocument, to an agent and allow the agent to work on that unsaved document.
 
I'm hoping it's my setup, but when I get the document in the agent, it only has one field - form, which is the name of my form associated with my xpage. None of the other xpage or form fields are available in the agent. I can set fields in the document and they get pushed forward to the xpage after the agent finishes, but I can't get a handle to any of the existing fields.
 

SSJS code in the button's onclick event:
 
var agent = database.getAgent("ContextAgent");
var doc = document1.getDocument();

if(null != agent) {
    try {
        agent.runWithDocumentContext(doc);
    } catch(e) {
        print("Error: " + e);
        return;
    }
}
 

ContextAgent code:

Dim session As New NotesSession
Dim doc As NotesDocument

Set doc = session.documentContext

If Not(doc Is Nothing) Then
    Print doc.said(0)
    Call doc.Replaceitemvalue("said", "Agent Value")
    Print doc.said(0)
End If

The first print statement shows nothing for the said field from the xpage, which should have a value of "1234". The second print statement shows "Agent Value", as it should, and that value is reflected back to the xpage once the agent completes and control is passed back to the SSJS.
Thanks, 
Scott. 
Apr 27, 2011, 4:42 PM
129 Posts
Re: Document Context Document is empty in agent when called with runWithDocumentContext fr...
There's two variants of NotesXSPDocument.getDocument().
 
One with no parameters, as in your code example, and one with a boolean flag, applyChanges. Try using document.getDocument( true ) 
 
http://public.dhe.ibm.com/software/dw/lotus/Domino-Designer/JavaDocs/XPagesExtAPI/8.5.2/com/ibm/xsp/model/domino/wrapped/DominoDocument.html#getDocument(boolean)
Apr 27, 2011, 5:01 PM
4 Posts
Re: Document Context Document is empty in agent when called with runWithDocumentContext fr...
That was it.
 
Tommy, thank you so much for the help.
 
Scott. 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal