Scheduled Job

ScheduledJob

Schedule a hook for execution at a later point in time

Kind: global class

new ScheduledJob(templateUid)

Create a new instance of the Scheduled Job class.

ParamTypeDescription
templateUidstringThe uid of the hook you want to schedule, must be an existing record in the scheduled_hook table.

scheduledJob.setContext(context) ⇒ this

The context is the single argument received by the job at runtime

Kind: instance method of ScheduledJob
Returns: this - Returns the instance of the class, providing the ability to chain methods.

ParamType
contextString

scheduledJob.setExecutionDate(date) ⇒ this

Set the execution date for this job

Kind: instance method of ScheduledJob
Returns: this - Returns the instance of the class, providing the ability to chain methods.

ParamType
dateDate

scheduledJob.schedule()

Schedule the hook based on jobUid, at the executionDate,

Kind: instance method of ScheduledJob
Example

const job = new ScheduledJob("job_uid");
const context = "some_info_to_send"
const date = new Date("01-12-2023 12:00:00"); // 1th of January 2023 at 12:00:00 (midday)
job
     .setContext(context)
     .setExecutionDate(date)
     .schedule();

// The job is fired at `date` and receives `context` as its only argument