Agent -Returning values

Hi All,I call a agent with the RunOnServer method for a document collection and the agent runs for each document.My question is when an error occurs in the agent while processing any of the documents,I would like to return the error why the agent failed and for which document(s) in the collection it failed?

I saw in Notes Help that RunOnServer returns a value of “0” if the agent ran successfully.How do I go about passing info back to the routine where I call my agent?

I would appreciate any ideas on this.

Thanks,

Sreeni.

Subject: Agent -Returning values

I assume you mean in LotusScript.

Instead of

Call agent.RunOnServer

Use

status = agent.RunOnServer

and test the value of “status”

Subject: Agent -Returning values

You can use parameter passing for passing information between two agents. In the Agent FAQ there is an article called “Run and RunOnServer passing parameter”. You will find explanation and coding examples.

Subject: RE: Agent -Returning values

Thanks for your response.I don’t want to pass values between agents.I am calling an agent thro RunOnServer in Click event of an Action.I want to return a Boolean type of value from the agent to the code in action button.

I would appreciate if you could help with some ideas.

I have read your articles and they are great source of information.I will look into the article you had mentioned.

Thanks,

Sreeni.

Subject: RE: Agent -Returning values

I’m looking for the same thing as Sreenivasan, and looked at the article. It is an excellent article, which admirably describes how to handle the status value returned by the NotesAgent.RunOnServer method. However, what we need to know is how to set the returned status from within the called agent. Is it possible to do this?

Subject: RE: Agent -Returning values

I am not sure what you are asking. The example show both the “top” (calling) and the “bottom” (called) agents. And the bottom agents has an example of how to set the return status in the called agents.

Subject: return value vs. input/output parameter

As far as I can see, the FAQ describes how to use a parameter document to pass information between top and bottom functions.

We were looking for a way of setting the return value (status) of the RunOnServer function itself to a nonzero value from within the bottom function; currently we have a lot of ‘top’ functions which execute agents and trap the exceptions which occur when RunOnServer returns a nonzero status. If we can set the status from within the bottom function, we don’t need to modify the existing ‘top’ functions, which we would need to do if we used parameter docs. Am I making sense?

Subject: RE: return value vs. input/output parameter

I see what you are after… but return value is set by the system, and cannot be set by the user. I described the mechanism that would allow you to achieve the goal with the functionality that exists. Hope it helps!