This is my first attempt at running an agent on the server. Right now the code is real simple as I am just making sure I have the basics down…
set Agent = DB.GetAgent(“(ServerAgent)”)
If Agent.RunOnServer = 0 then
MessageBox “Success.”
else
MessageBox “Failure.”
end if
The “Success” message displays, but the Notes log contains the error: You must specify a parent database.
How do I do that? The Parent property of the agent is read-only and is the name of the database which contains the agent.
Thanks for your help.
–Ron
Subject: Error attempting to run agent on server.
You’re missing a whole lot of code there. At a minimum, the code would need to look like this:
Option Public
Option Declare 'don’t ever come crying for help if this line is missing
Sub Initialize
'could also be Sub Click or whatever
Dim s As New NotesSession
Dim thisDb As NotesDatabase
Set thisDb = s.CurrentDatabase
Dim agent As NotesAgent
Set agent = thisDb.GetAgent(“(ServerAgent)”)
If agent.RunOnServer = 0 Then
Messagebox "Success"
Else
Messagebox "Failure"
End If
Note that there is a reference chain that goes from session to database to agent that is absolutely required to get a handle on the agent.
Subject: RE: Error attempting to run agent on server.
My appologies for not being more clear in my messsage. The problem is not with the calling agent, but with the called agent (“ServerAgent” that I am attempting to run on server).
I do have all that code is both agents. (Option Declare is part of my profile).
When I copy the code from Julie K.'s example (Agent FAQ - Run and RunOnServer article) it works. However, the agents that I created aren’t working, so it back to starting over with clean, basic agents and building from there.
Thanks for your suggestions and help.
–Ron
Subject: RE: Error attempting to run agent on server.
I couldn’t make the assumption – I’ve seen too many instances of people trying to run partial code. The “parent database” should be gettable in the runonserver agent through either session.CurrentAgent.Parent or session.CurrentDatabase. The latter just seems more practical to me (there’s less typing and I’m a notoriously slow typist). An example of a broken agent would help a lot.