batch process

hi!
I am trying to create a simple batch process that will insert records in my table

function batchprocessinsert_onOpen() {	
	// add a job that runs every day at 4:10pm and every 5mins
	var dateNow = new Date();
	plugins.scheduler.addCronJob('registrationcleanup', '0 10/5 16 ? * *', globals.insertRecord(), dateNow)
}

function insertRecord() {

	var signupFS = databaseManager.getFoundSet(DB_SERVER_NAME, "signup")
	signupFS.newRecord();
	signupFS.effectivedate = new Date();
	databaseManager.saveData(signupFS)
}

deployed the solution.

Create a new batch process
Solution: batchprocessinsert
I did not set any arguments, username and password.

Clicked Add
Clicked Start
status: Is running

I did not see any records in my table.

Is the username and password required? I do not have a login form in my solution.

  1. how long did you wait?
  2. you specified startdate, which isn’t necessary as it’s an optional argument.
    won’t do any harm, but won’t help either…

The problem is in the following line:

rogel:

plugins.scheduler.addCronJob('registrationcleanup', '0 10/5 16 ? * *', globals.insertRecord(), dateNow)

Remove the brackets from the global method name otherwise it will get executed straight ahead. The line should be:

plugins.scheduler.addCronJob('registrationcleanup', '0 10/5 16 ? * *', globals.insertRecord, dateNow)

ngervasi:
The problem is in the following line:

rogel:

plugins.scheduler.addCronJob('registrationcleanup', '0 10/5 16 ? * *', globals.insertRecord(), dateNow)

Remove the brackets from the global method name otherwise it will get executed straight ahead. The line should be:

plugins.scheduler.addCronJob('registrationcleanup', '0 10/5 16 ? * *', globals.insertRecord, dateNow)

Still unsuccessful. Should the method(globals.insertRecord) be the solution onopen?
http://www.servoymagazine.com/home/2007/02/running_a_metho_1.html

rogel:

function insertRecord() {
var signupFS = databaseManager.getFoundSet(DB_SERVER_NAME, "signup")
signupFS.newRecord();
signupFS.effectivedate = new Date();
databaseManager.saveData(signupFS)

}

Are you sure that DB_SERVER_NAME contains a valid value?
Anyway first thing is to check the log to see if the method runs, you could also fire some application.output() when you init the cronjob and when you run the method so you can check the server log to see what happens.

why not run it as a solution in developer so you’ll be able to debug it?
Seems easier than just guess around what might be wrong…

My start would be skipping the scheduler and just call the insert function from the batchprocessinsert_onOpen function.

mboegem:
why not run it as a solution in developer so you’ll be able to debug it?
Seems easier than just guess around what might be wrong…

My start would be skipping the scheduler and just call the insert function from the batchprocessinsert_onOpen function.

Thanks Marc! Indeed there is an error in the method.

Regards,
Rogel