Subject: How to trigger another agent without a user
You can get the agent via the NotesDatabase.GetAgent and then call Run. Here you can even supply a parameter. Please have a look at the designer’s help for more details.
Subject: RE: How to trigger another agent without a user
To pass a parameter to a second agent you will need to create a temporary document to store your parameter and then pass the note ID of the temp document to the second agent. A simple example is below:
Dim s As New notessession
Dim db As notesdatabase
Dim agent As notesagent
Dim tempDoc As notesdocument
Set db=s.currentdatabase
Set agent=db.getagent("NAME_OF_SECOND_AGENT_HERE")
'set a temp doc that has the variables needed for the second agent
'the server agent will run using this doc
Set tempDoc=db.createdocument
tempDoc.form="foTemp"
tempDoc.QUERY_STRING="YOUR VALUE HERE"
'add additional values to pass here...
'make the current user an author so they can delete the temp doc
Dim tempItem As notesitem
Set tempItem=tempDoc.replaceItemValue("tempAuthorChoices",s.effectiveusername)
tempItem.isAuthors=True
Call tempDoc.save(True, True)
'run the agent on the server (gets the number and stores it in the temp doc)
Call agent.runonServer(tempDoc.NoteID)
'remove the temp doc
Call tempDoc.remove(True)
2nd agent has the following line to get the passed document:
Set doc=db.getdocumentbyID(s.currentagent.ParameterDocID)