Class: Job

$.jobs. Job

$.jobs.Job Represents an XS scheduled job.

new Job(constructJob)

A scheduled job.
Scheduled jobs are created via .xsjob files and can be used to define recurring tasks that run in the background. The JavaScript API allows developers to add and remove schedules from such jobs.
Parameters:
Name Type Description
constructJob Object parameter object to construct job object
Properties
Name Type Argument Description
uri String absolute or relative path to the xsjob file to construct an object for
sqlcc String <optional>
absolute or relative path to the xssqlcc file to use only for database operations that manipulate the job. To be set in case the user that runs the code that adds or deletes a schedule does not have the necessary privileges.
Properties:
Name Type Description
schedules $.jobs.JobSchedules Object that allows manipulating a job's schedules.
Throws:
Throws an error if the constructJob object is not valid or looking up the job fails.
Example
var myjob = new $.jobs.Job({uri:"my.xsjob", sqlcc:"sqlcc/otheruser.xssqlcc"});

Members

concurrencyHint

Retrieve hint about free CPU resources taking into account the recent average CPU load. Should be used with care.
Example
var hint = myjob.concurrencyHint;

Methods

activate(credentials)

Activates an XS Job that has already been configured.
Parameters:
Name Type Description
credentials Object it is recommended to store credentials in the secure store $.security.Store
Properties
Name Type Description
user String name of the user to run the XS Job. Must be the one already configured at the XS Job
password String password of this user
Throws:
Throws an error if activating the job fails (e.g., due to invalid credentials or missing privileges)
Example
myjob.activate({
   user: "JOBUSER",
   password: "MyPassWd1"
});

configure(config)

Configure an XS Job. The function provides additional means to programmatically configure an XS Job. Configuring an XS Job via the XS Job Dashboard yields the same result. Configuration must be done prior to activate/deactivate an XS Job.
Parameters:
Name Type Description
config Object anonymous object to configure the job. The config object contains credentials. It is recommended to store these in the secure store $.security.Store
Properties
Name Type Argument Description
user String name of the user to run the XS Job
password String password of the user
locale String sets the language encoding required for the locale in which the job runs
status Boolean status of the XS Job: true for active, false for inactive
start_time Date | Object set start time in UTC of the time frame in which the job will be scheduled. Can either be a Date object or an object with the following properties:
Properties
Name Type Argument Description
value String start time in UTC as a String
format String <optional>
specify the format of the value string
end_time Date | Object set end time in UTC of the time frame in which the job will be scheduled. Can either be a Date object or an object with the following properties:
Properties
Name Type Argument Description
value String end time in UTC as a String
format String <optional>
specify the format of the value string
session_timeout Integer <optional>
configures the timeout in seconds for the session in which the XS Job executes. If set to 0 the configuration in xsengine.ini->scheduler->sessiontimeout will be used
Throws:
Throws an error if configuring the job fails (e.g., due to invalid credentials or missing privileges)
Example
myjob.configure({
   user: "JOBUSER",
   password: "MyPassWd1",
   locale : "EN",
   status: true,
   start_time: {
       value: "25 01 2014 11:57:19",
       format: "DD MM YYYY HH:MI:SS"
   },
   end_time: null
});

deactivate(credentials)

Deactivates an XS Job that has already been configured.
Parameters:
Name Type Description
credentials Object it is recommended to store credentials in the secure store $.security.Store
Properties
Name Type Description
user String name of the user to run the XS Job. Must be the one already configured at the XS Job.
password String password of this user
Throws:
Throws an error if deactivating the job fails (e.g., due to invalid credentials or missing privileges)
Example
myjob.deactivate({
   user: "JOBUSER",
   password: "MyPassWd1"
});

getConfiguration()

Retrieve current configuration of an XS Job as object.
Properties:
Name Type Description
user String name of the user to run the XS Job
locale String current language encoding required for the locale in which the job runs
status Boolean status of the XS Job: true for active, false for inactive
start_time Date start time in UTC as a Date object
end_time Date end time in UTC as a Date object
session_timeout Integer configures the timeout (in seconds) for the session in which the XS Job executes.
Throws:
Throws an error if retrieving the configuration of the job fails (e.g., due to missing privileges)
Example
var configuration = myjob.getConfiguration();