GetAgent

Hello,I need to run a back-end agent that uses lsxlc connections to DB2.

I have done this many time with success from the back-end however I need to call this agent from the front-end and pass it some argument and return some parms.

Is there a way of doing a agent call from another with arguments being passed?

The application that we are creating will pop-up a subform when a user creates a new document.

At that point they will enter a Location and Order Number and click OK.

This is where I need to call my back-end agent with arg1, arg2, connect to our i5, run a stored procedure the will retrieve data, pass back the data as a parm string to the calling agents and create a document and fill fields with the values from the call.

Make sense?

Subject: GetAgent

Hi,

By using the method Run or RunOnServer under NotesAgent class, it is no problem to pass arguments and retrieve return value to and from backend agent. The idea is to store all the

input parameters in a temp document (saving not required). Pass the NoteID as parameter to the agent.

Example: myAgent.RunOnServer(tempDoc.NoteID)

We use this type of agent every minute for front end user to get ODBC data.

Below is the Lotus Domino Designer 6.5.1 Help on the RunOnServer method:

This agent runs the agent named “Agent to be run parameter LotusScript,” passing it the note ID of a newly created document.

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim agent As NotesAgent

Set db = s.CurrentDatabase

REM Create document containing data to be passed

Set doc = New NotesDocument(db)

doc.TriggerUserName = s.UserName

Call doc.Save(True, False)

REM Start agent and pass note ID of document

Set agent = _

db.GetAgent(“Agent to be run parameter LotusScript”)

If agent.RunOnServer(doc.NoteID) = 0 Then

Messagebox "Agent ran",, "Success"

Else

Messagebox "Agent did not run",, "Failure"

End If

End Sub

This is “Agent to be run parameter LotusScript.” It accesses the passed note ID through ParameterDocID, accesses the referenced document, and removes it.

Sub Initialize

Dim s As New NotesSession

Dim agent As NotesAgent

Set agent = s.CurrentAgent

Dim db As NotesDatabase

Dim doc As NotesDocument

Set db = s.CurrentDatabase

REM Get document used for passing data

Set doc = db.GetDocumentByID(agent.ParameterDocID)

REM Send mail containing passed data

Dim memo As New NotesDocument(db)

memo.Form = “Memo”

memo.SendTo = s.UserName

memo.Subject = “Message from LotusScript agent”

memo.Body = "The agent was started by " _

& doc.TriggerUserName(0)

Call memo.Send(False)

REM Delete document used for passing data

Call doc.Remove(True)

End Sub

===========

Good Luck

Subject: GetAgent

How would you pass the arguments to that agent? Is it possible that the agent gets the uidoc and reads the values entered?I would prefer it to shift all necessary functions of the agent into a library. Then you can use the functions in this library with the agent and also with an action and you can pass values as you need.

An other possibility is that you can write the arguments into an textfile that you place at a specific directory. Then let that agent look if that file is there. If it exits the agent runs using these values and if work is done the file should be deleted by the agent. Does the file not exist the agent runs as usual.

Hope it helps

Subject: RE: GetAgent

Martin,That is my question… “How would I do that”?

I was also thinking about trying this from a postopen event.

I will post if it works.