How to programatically schedule an agent?

Hi,

Is there any way to programatically schedule an agent?

If it is possible then how?

Please help.

Thanks in advance.

Abhishek.

Subject: How to programatically schedule an agent?

It really depends on what you are trying to accomplish.

What is the logic you are trying to match? Basically you will have to created a scheduled agent that includes all of your schedule logic.

perfect example–if you want to write a scheduled agent that only runs on Jan. 1, you would create a scheduled agent that runs every month on the first and write logic to check if it is January 1. If that condition is met, then call the other agent.

It’s pretty much the only way you can do it, and if you have more complex logic, you might need to create multiple scheduled agents to call your agent on a schedule.

hth.

brandt

Subject: RE: How to programatically schedule an agent?

Brandt is correct- I have a database that has an agent that is scheduled to run every day- the first 20 lines of code look at our fiscal calendar database for fiscal period end dates, and then calculates “backwards” from there- so, if it is 14 days before the end of the fiscal period, something happens; when it is 3 days before the fiscal period ends, something else happens. I have put a snippet of the code below:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim nabdb As New NotesDatabase("ServerName","names.nsf")	

Dim acl As NotesACL

Dim aclentry As NotesACLEntry

Dim OURusers As NotesView

Dim nabdoc As NotesDocument	

Set OURusers = nabdb.getview("OURUsers")

Set db = session.CurrentDatabase

Set acl = db.ACL

Set aclentry = acl.GetFirstEntry



Dim fiscaldb As New NotesDatabase( "ServerName", "Apps\Finance\FiscalCalendar.nsf")

Dim fiscalview As notesview	

Dim DBProfile As NotesDocument

Set DBProfile = db.GetProfileDocument("DB Profile")

Set fiscalview=fiscaldb.GetView("Fiscal Calendar")

Set fiscaldoc=fiscalview.GetFirstDocument

Do While Not(fiscaldoc Is Nothing)

	Dim FiscaldateTime As New NotesDateTime( fiscaldoc.begindate(0))

	

	'This section is for month end roll

	

	FiscaldateTime.LSLocalTime= fiscaldoc.begindate(0)

	Call FiscaldateTime.AdjustDay( -8)

	If Format(fiscaldatetime.dateonly,"MMDDYY")=Format(Cstr(Today),"MMDDYY") Then

		subjecttext="Your forecast is due by the close of work tomorrow"

	Else

		FiscaldateTime.LSLocalTime= fiscaldoc.begindate(0)			

		Call FiscaldateTime.AdjustDay(-12)

		If Format(fiscaldatetime.dateonly,"MMDDYY")=Format(Cstr(Today),"MMDDYY") Then

			subjecttext="Your Forecast is due next Monday"

		End If

	End If

Subject: RE: How to programatically schedule an agent?

Dear All,

I have one doubt, that when this Agent will call, is it run manually or schedule?

The same problem I am facing, that I have a schedule agent it runs every day in the morning automatically at 10AM.

can we set the scheduled time programatically?

Regards

Ashish

Subject: RE: How to programatically schedule an agent?

It would be scheduled.

You can adjust the design of an agent, including when it runs, by exporting it to DXL, modifying the DXL data, and importing it. You must then sign the agent with an authorized ID (which can also be done in the code).

The schedule information is encoded in a binary item in the agent design note, so there’s no way to access that information directly by poking through the items in LotusScript. You could do it with an API program.

Bear in mind that if you inherit design from a template, the template will clobber your changes in the nightly design refresh unless you set the protect from design refresh flag.