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



Jul 31, 2013, 9:00 AM
4 Posts

Agent changes not detected

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 3

Hi
 

Please see code below which is executed on a button in an XPage. I am triggering an agent. Agent makes some changes to doc. Then I try to detect the changes that the agent has done, but the ssjs is not detecting the changes.
 


Any ideas please? Here is a sample code from the xpage:

//server side JS
var doc : NotesDocument = document1.getDocument(true); //back-end of existing xpage doc
var noteid = doc.getNoteID();
var myFldName = doc.getItemValueString("MyFldName");
pdfAgent.runOnServer(noteid); //agent makes changes to MyFldName text field

var i = 0;
var found = false;


//try to detect field change done by agent above
do {
    java.lang.Thread.currentThread().sleep(2000);
    doc.recycle();
    doc = null;
    doc = session.getCurrentDatabase().getDocumentByID(noteid);

    var myFieldNew = doc.getItemValueString("MyFldName");
    if (myFldName != myFieldNew) {
      found = true;
      print(i + " FOUND! " + myFieldNew);
    } else {
      print(i + " NOT found " + myFieldNew);
   }
  i++;
} while (i < 5 && !found)

 

Jul 31, 2013, 1:59 PM
586 Posts
Well,

I guess the best thing to do is to not use an agent.  To redo that code - LotusScript I assume - into SSJS or Java.  It sure would help performance in the long run.

If the agent code is too daunting could you not save a list of the unids to the doc you pass into the agent...  then when the agent returns control you RE-GET the document you passed in and read the field that has any saved UNIDS...  and then process against that?

That's how it's typically done I THINK.

 

Dave

Jul 31, 2013, 8:56 PM
4 Posts
Re: Well

Hi David

Thanks a lot for your reply. I have use a temporary doc to pass as document context, and I was able to detect the values changed by the agent from it.

Running an agent from ssjs is not ideal, but the agent is not straight forward (thought not impossible) to convert to ssjs since it's a java agent using a few external jars to convert html to pdf. So I thought I leave it as an agent.

Jul 31, 2013, 10:09 PM
17 Posts
Have you tried runWithDocumentContext

The agent.runWithDocumentContext() API runs an agent and passes a saved or unsaved in-memory document to the DocumentContext property of the called agent.


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