Angent doesn't work

Hi everyone, I run agents to replicate documents from dev03 to dev02.

The coding is not working below. The profile setting up is fine. The interval=0(just for today).

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