< Back

Document Subject: Call a Notes Agent from another Agent using Lotusscript
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#AgentAgent or http://A555F9/nn.nsf/ByAlias/AgentAgent

How do you call an agent from another agent?




This can be done but can have strange results, as the second agent is run in the background.

 

To demonstrate it:

Create an agent called ag1 which has target of "none".

 Dim s As New notessession
Dim db As NotesDatabase
Set db = s.currentdatabase
Dim ag As notesagent
Set ag = db.GetAgent("ag2")
Msgbox ag.lastrun
Call ag.run
Delete ag 'delete the handle to reload it
Set ag = db.GetAgent("ag2")
Msgbox ag.lastrun

Create an agent called ag2 which has target of "none".

 Dim s As New notessession
Dim db As NotesDatabase
Set db = s.currentdatabase
Dim mdoc As notesdocument
Set mdoc = New notesdocument(db)
mdoc.form="Memo"
mdoc.sendto="adam foster"  '  change this address to your email etc
mdoc.subject="ag2 " & Now
Call mdoc.send(False)

Run agent ag1 fom the database's Actions list or by right clicking on the agent in the designer's agents list.