JSMA jobs
Overview
The JSMA jobs allows you to create and run background jobs.
Index
Methods
The JSMA job provides the following methods:
job jobs.execute(title, profile, [data], [portal], [scheduledDate])
Creates a new job and queues it for execution.
Example
... var scheduledDate = new Date(); //alternative libs are available for manipulating JS dates scheduledDate.setTime(scheduledDate.getTime() + 3600 * 1000); var portal = portals.current; var data = JSON.stringify({ some: { arguments: ['with', 'deep', 'nesting'] } }); var job = jobs.execute(title, 'myJobProfile', data, portal, scheduledDate); ...
Parameter title:string (required)
The title for the particular job.
Parameter profile:string (required)
The name of the JobProfile to be used. If no valid profile name is supplied, an exception will be raised.
Parameter data:string (optional)
A JSON string. This will be parsed and made available to the handler as the first argument. (args[0]
)
Parameter portal:portal (optional)
The portal in which scope the job is run. Either a JSMA portal, or the uuid of a portal. Defaults to the portal of the request which called this method.
Parameter portal:scheduledDate (optional) (Since IFE 4.4.x)
A JS Date object containing the earliest execution time for the job. (It might get executed later but never earlier)
job jobs.findById(id)
Retrieve a job by ID.
Example
... var job = jobs.findById(1); ...
Parameter id:integer (required)
The ID to look up.
job jobs.current
Helper function to access the Job from within itself.
Example
... var job = jobs.current; ...