Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
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://www.notesninjas.com/#AgentAgent or http://www.notesninjas.com/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.

 

 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
man and boy by Tony Parsons
British book of the year 2000. Great book, hard to put down, but I nearly threw it away half way through. You'll know why when you read it.
See at: Amazon.co.uk | Amazon.com |