Jayson Rondina
Jayson Rondina

Reputation: 149

how to run agents in xpages from a web browser?

I got this problem and started googling about it, but no direct answer were pulled out. My query problem is, I'm doing an xpage project and I need to run an agent that uses lotusscript as a language. The agent is used to read a TSV text file and create notes document from each record there. Independently running the agent went very good, no problem. But when I tried to run it from xpage using this script :

var doc = database.createDocument();
var field = getComponent("filePath");
var agent:NotesAgent = database.getAgent("UploadTSV");

if (agent != null) {
    agent.runWithDocumentContext(doc);
    TSVDoc.setValue("filePath","Agent run");
}
else{
    TSVDoc.setValue("filePath","Agent did not run");
}

it did not run. I'm just wondering what I did wrong. Thank you in advance.

Upvotes: 1

Views: 998

Answers (1)

Oliver Busse
Oliver Busse

Reputation: 3395

My way to do this would be to trigger the agent (either it's based on a page load event or on a user click event) via client Javascript. The URL to run an agent is nothing more than

http://yourhost/yourapp.nsf/youagent?openagent

So I'd just make a AJAX call to that URL to run the agent. To get return values (errors of anything else) I'd add some code to the agent's print output. Print statements (in Lotusscript) in agents called from the browser produce a HTTP response. Similar for agents written in Java but there you have to do more than simple sysouts.

Upvotes: 4

Related Questions