Agent.RunOnServer

Hello, I used the Debug go through with the coding, the name of the agent is correct, the “SERVERNAME” of the agent is “”, I was wondering what the “SERVERNAME” should be? it should be the servername which contains the agent (run agent on it) or should be the server name which contains replication database?

Thanks,

Linda

Subject: Agent.RunOnServer.

HEllo Linda,

Servername is the server on which agent is to be un.

Regards,

Munish Kaushik

Subject: RE: Agent.RunOnServer.

Thanks Munish. if it is the server on which agent is to be run, it should not “”. for example, if database contains the agent on DEV03, it should “DEV03” instead of “”. does it?

Thanks,

Linda

Subject: RE: Agent.RunOnServer.

Hello Linda,

If the agent is not scheduled, this property returns an empty string.

Hope this clears your doubts.

Best Regards,

Munish Kaushik

Subject: RE: Agent.RunOnServer.

Hello Munish, I see. if you have a minute, would you please help me take a look coding below, it made me crazy.

My problem is that seems agents run fine(I have checked the agent log, went through the debuger), but no more docs was replicated. I want to call 2 agent to replicate some docs from Dev03 to Dev02 server.

Is therer any setting up I should do on both Dev02 & Dev03 server?

I thank you very much for your help!

Linda

Replication formula for database on destination server is

rep:=@If(Form=“ReclassDisclosureItem”;@If(PublicDoc=“Y”;“Y”;“”;“Y”);

SELECT rep=“Y”

I thank you for your help!

Linda

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Dim replicadb As NotesDatabase

Dim profileview As NotesView

Dim profiledoc As NotesDocument

Dim dt As NotesDateTime

Dim currdt As NotesDateTime

Set currdt =New NotesDateTime(Today)

Set db=s.currentdatabase

'**************************************************************

'GET THE PROFILE ELEMENTS

'**************************************************************

Set Profileview=db.GetView(“vwConfigView”)

Set profiledoc=profileview.GetFirstDocument

If profiledoc Is Nothing Then

Msgbox “The application profile cannot be found. Replication cancelled.”,0+16,“Configuration Error”

Exit Sub

End If

lastrep=profiledoc.LastReplication(0)

repinterval=profiledoc.ReplicationInterval(0)

repserver=profiledoc.ReplicationServer(0)

'**************************************************************

'DETERMINE IF THE LAST REPLICATION INTERVAL HAS PASSED.

'IF NOT, DISPLAY MESSAGE TO USER & EXIT

'**************************************************************

If Cstr(lastrep)=“” Then Goto StartReplication

If Cstr(repinterval)=“” Then Goto StartReplication

Set dt=New NotesDateTime(lastrep)

dt.AdjustDay(repinterval)

If dt.lslocaltime>Today Then

Msgbox "The specified time frame has not passed until replication can occur again. Please wait until " & dt.localtime & “, and try again.”,0+16,“Replication Error”

Exit Sub

End If

'**************************************************************

'VERIFY A REPLICA EXISTS ON THE SERVER TO REPLICATE WITH

'**************************************************************

Set replicadb = New NotesDatabase( “”, “” )

If Not(replicadb.OpenByReplicaID( repserver, db.ReplicaId )) Then

Msgbox “A replica of this database does not exist on “& repserver &”. Please adjust the profile document”,0+16,“Configuration Error”

Exit Sub

End If

StartReplication:

profiledoc.LastReplication=Today

profiledoc.Save True, False

Dim agent As NotesAgent

Set agent = db.GetAgent(“(ReplicateDatabase)”)

If agent.RunOnServer = 0 Then

currdt.AdjustDay(repinterval)

Msgbox "Replication was completed successfull with " & repserver & ". You will be able to replicate again on " & currdt.localtime,0+64,“Replcation Completed”

Else

Msgbox “An error occured duriing replication. Please check the notes log.”,0+16,“Replication Error”

End If

End Sub

Here is the “ReplicateDatabase” agent below

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Dim notesrep As NotesReplication

Dim profileview As NotesView

Dim profiledoc As NotesDocument

Dim dt As NotesDateTime

Dim currdt As NotesDateTime

Set db=s.currentdatabase

Set notesrep=db.ReplicationInfo

'**************************************************************

'GET THE PROFILE ELEMENTS

'**************************************************************

Set Profileview=db.GetView(“vwConfigView”)

Set profiledoc=profileview.GetFirstDocument

repserver=profiledoc.ReplicationServer(0)

notesrep.Disabled=False

notesrep.Save

db.Replicate(repserver)

notesrep.Disabled=True

notesrep.Save

End Sub

Subject: RE: Agent.RunOnServer.

Hi Linda,

There seems to be an error in your Replication formula. check with that and get back to us.

The following line has an error and hence there is a problem in replication. You are missing a “)”

rep:=@If(Form=“ReclassDisclosureItem”;@If(PublicDoc=“Y”;“Y”;“”;“Y”);

should be rep:=@If(Form=“ReclassDisclosureItem”;@If(PublicDoc=“Y”;“Y”;“”);“Y”);

Hope this helps…

Best regards,

Munish Kaushik

Subject: RE: Agent.RunOnServer.

Hi Munish, Missing a ) was occurred when I copied and pasted. It is ok in my PC.

The problem was we should add two server names on the ACL as server manage for both replication databaser. otherwise, no data replicated. Nothing wrong with agent coding. By the way, I saw my boss opened a database to check agent log on the server, but i forgot what is the database name, do you know which database I should use to check agent log on the server?

Many thanks for your help and kindness.

Best regards,

Linda

Subject: RE: Agent.RunOnServer.

Hey Linda,

Good to hear that your problem got solved. I knew this fact that you should have two names in the ACL, just couldn’t figure out…

The database on which you can see the log is log.nsf.

Have a great day ahead… Is it day there… don’t know :slight_smile:

Regards,

Munish Kaushik