Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run lotusscript agent from Xpages

I have written lotusscript code in Agent, i need to run the agent by on clicking the button in Xpage.

How could i achieve?

Thanks in advance

like image 734
Richard Arun kumar Avatar asked Dec 17 '25 07:12

Richard Arun kumar


1 Answers

A problem with this solution could be that when you want to use data which is manipulated in the agent you have to reload the notes document in your xpage. This can be done with the following lines of code:

        var ag = database.getAgent("agentname");
    if(ag != null){
      var id = doc.noteid;
      ag.runonserver(id);
      doc.recycle();
      doc = database.getdocumentbyid(id);
       // check if the agent did its job.
       // if so do stuff otherwhise report this to the user?
    }

Since version 8.5.2 there is a new method added to the agent class

agent.runWithDocumentContext(NotesDocument doc);

This method uses the in memory document of the xPage. Therefore you don't need to save your document in the agent itself but you can make your changes and exit the agent code. The xpage can directly make use of the changes made. This saves you a lot of hassle with checking if the agent did his job, reloading the document etc etc.

For this to work you have to set the options of your agent to

  1. Run as web user
  2. Allow restricted operations
  3. the type of agent is "Agent list selection" with target "none"
like image 166
jjtbsomhorst Avatar answered Dec 23 '25 06:12

jjtbsomhorst



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!