xPages to Notes Agent Issue

New to 8.5 here (did not do 8.x) and starting to build a xPage application for our blackberry handhelds. This is for approving requests remotely. Multiple request Types come in but a single form in this DB. xPages will display based on type of request coming in. User reviews data and then clicks approve or reject. When they click approve it is supposed to mark the request approved and save it to remove from their queue. Then it needs to connect back to the parent request DB (R7 database) and update the request there and continue it on for processing. I was going to have my approve button run an agent and use that agent to update the request in the parent request database.

Being a newbie at xPages I am mucking it up and probably missing something very simple.

At the end of my actions I have an execute script to call the agent that is like this:

1: var currDB = session.getDatabase(session.getServerName(),“Mobile\MobReqTrack.nsf”);

2: var agtProtocall = currDB.getAgent(‘agt_protocallApprove’);

3: print("JISASC7 - calling agent - " + agtProtocall.getName() + " with " + requestDoc.getValue(“req_requestID”));

4: print("JISASC7 - RequestDocID - " + sessionScope.requestDocID);

5: var reqDocID = @Text(sessionScope.requestDocID);

6: agtProtocall.runOnServer(reqDocID);

When I click approve I get the following error message:

Error while executing JavaScript action expression

Script interpreter error, line=6, col=14: Exception occurred calling method NotesAgent.runOnServer(string) null

Lines 1-5 execute just fine, but line 6 is where I am unable to get it to work.

Again I am sure it is just a simple thing I am mucking up, but any help & guidance in the right direction would be greatly appreciated.

Thanks in advance,

Steven

Subject: On the face of it it looks OK

agtProtocall.runOnServer(reqDocID); should work. Though there maybe something up with @Text(sessionScope.requestDocID). Try it again without the @Text.

And maybe try

agtProtocall.run(reqDocID) - just to see if the if that makes a difference.

Or even just try

agtProtocall.run() to make sure that the agent runs

Subject: Figured it out

Paul,

Thanks for the help. Based on your response I figured I was doing something wrong with my agent. I looked at it properties since it was not working thought maybe I set something wrong. It was set to run as an action menu selection on selected documents. I switched it to an Agent List Selection on None for documents. Which made it have the () around the agent name. I updated my currdb.get agent to include the parens and that worked.

Thanks for the help.

Steven

Subject: Thanks so much for posting this solution…

I am just now trying to “catch up” to everyone who have jumped onto the xPages bandwagon, and had the exact same issue.

I was sure that I was make much more complex errors with my SSJS or something, and spent an embarrassing amount of time trying to determine the cause of the issue.

In the end, my problem was exactly the same as yours, as was solved within a couple of minutes once my eyes were opened.

Thanks heaps for posting your solution - I might have still been pulling my hair out!

Cheers, T.

Subject: use try - catch

Hi

I suppose you use try - catch clause and print errors to console. It gives better error messages.

try {

        //your code

} catch(e) {

        print("<<<error " + e + ">>>");

}