JS Batch job example


#1

Following is an JS Batch job example that you can run without need for code provisioning.

Define what the job will do inside processBatch

var doStart = function (job) {
  JSBatchJob.scheduleBatch(job, JSBatchJobBatch.make());
};
var allComplete = function () {
};
var processBatch = function (batch, job, options) {
  // your code goes here
};

Lunch the job

var spec = JSBatchJobSpec.make({
  allComplete      : allComplete.toString(),
  doStart             : doStart.toString(),
  processBatch   : processBatch.toString(),
  context: {
    // pass in any parameters for the processBatch
    // key1: value1
  }
});
// launch job
var job = JS.batchJob(spec);

If you want the job to run asap

job.setPriority(1)