Agent.runonserver is not running on the server

I'm trying to run an agent that will sign other agents with a generic ID.

My first agent is a "Run from the action bar" one where it takes the document(s) I've selected in a view. These documents contain the server, database, agent name and the current signer of the database. (One document per server/db/agent.)

I gather this information, and do an agent.runonserver(Noteid) - NoteID of the document I wish to pass to this agent.

The agent I'm calling upon is called "SignIt". It's a scheduled agent with no schedule. I've set the server it should run on to the specific server. It is signed by the generic ID I want.

I initiate it from my action-bar menu and it runs but on my client rather than the server. (I verified this with a print statement in the "SignIt" agent. It comes up in my message bar and not the server logfile.)

End product is the agent I'm trying to sign ends up with my ID, not the generic one.

Maybe you should post the code you are using for this.

The settings of the agent to run is unimportant because RunOnServer will run the agent on the server you get the Agent from.

So if agent is an instance of an Agent on Server1 it will be run there, not the server configured in this agent

Sorry, the code;

%REM
	Agent Sign Agents
	Created Jan 11, 2021 by Chris James
	Description: This takes the agents specified by the document(s) selected
	and passes them off to the "SignIt" agent which runs on the server to
	actually sign the agent. The SignIt agent itself must be saved/signed
	by theGeneric Signer ID.
%END REM
Option Public
Option Declare

Sub Initialize
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim wk As New NotesUIWorkspace
Dim session As New NotesSession
Dim agent As notesagent
Dim view As NotesView
Dim dc As NotesDocumentCollection
Dim uidoc As NotesUIDocument

Dim ans As Boolean

Set db = session.CurrentDatabase
Set agent = db.Getagent("SignIt")

' This is may be run from the form or documents selected in a view.

If wk.CurrentDocument Is Nothing Then
	Set dc = db.UnprocessedDocuments
	Select Case dc.Count
	Case 0:
		ans = MessageBox("You must select one document to have its agent signed",0,"Nothing selected")
		Exit Sub
	Case Else:
		Set doc = dc.GetFirstDocument
		While Not doc Is Nothing
			Call agent.Runonserver(Doc.noteid)
			Set doc = dc.GetNextDocument(doc)
		Wend
		Print "Agents signed"
		Call wk.CurrentView.DeselectAll
		Call wk.ViewRefresh
End Select
Else
	Set uidoc = wk.CurrentDocument
	Set doc = uidoc.document
	Set doc = dc.GetNextDocument(doc)
	Call agent.Runonserver(Doc.noteid)
	Call uidoc.Refresh
End If

End Sub

%REM
	Agent SignIt
	Created Jan 12, 2021 by Chris James
	Description:  If you make any changes to this agent, do it as the generic Signer
	so that agents this agent signs assume its ID.
	
	This routine is called from the "Sign Agents" agent. It has to run on the server
	so as to assume the ID of generic Signer.
%END REM
Option Public
Option Declare

Sub Initialize
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim adb As NotesDatabase
	Dim doc As NotesDocument
	Dim thisAgent As NotesAgent
	Dim agent As NotesAgent
	
	Set thisagent = session.Currentagent
	Set db = session.Currentdatabase
	Set doc = db.Getdocumentbyid(thisagent.Parameterdocid)
	Set adb = New NotesDatabase(doc.server(0),doc.database(0))
	If Not adb.Isopen Then Call adb.open(doc.server(0),doc.database(0))
	Set agent = adb.Getagent(doc.agent(0))
	If agent Is Nothing Then 
		Print "Could not sign the agent"
	Else
		Call agent.save()
		Print "Agent Signed"
	End if
End Sub

From your code the SignIt agent will always be run on the replica of the database you are calling the first agent.

Is this a local replica ?

While I do have a local replica, I'm running this from the server replica. I know it should run on the server, but it's not.

This post is 2 years old, I don't know if it will help, but today I had this problem and solved it by changing the trigger of the agent invoked by RunOnServer to On event -> Action menu selection.

In my case I was executing an agent with RunOnServer from the WebQueryOpen event of a form

Example:
Agent1 runs Agent2.RunOnServer
So Agent2 trigger should be On Event -> Action menu selection

I hope this helps someone