$k. ScriptJob

new ScriptJob()

Represents a script job

Extends

Methods

(static) cancelSchedule(name)

Cancel a job schedule

Parameters:
NameTypeDescription
namestring

The schedule name

Version
  • Experimental feature, might be removed at any time
Since
  • 5.5.0

(static) schedule(name, interval, user, scriptName, functionNameopt, runInTransactionopt)

Add a job schedule

Parameters:
NameTypeAttributesDescription
namestring

The schedule name

intervalnumber

The interval in minutes

usernil

The user

scriptNamestring

The script name

functionNamestring<optional>

The function name

runInTransactionboolean<optional>

Boolean

Version
  • Experimental feature, might be removed at any time
Since
  • 5.5.0

insert()

Add the job to the job queue

Overrides

setFailureFunctionName(functionName)

Set the name of the function to call when the script job fails.

Parameters:
NameTypeDescription
functionNamestring

Name of the function to call

Since
  • 5.3.3

setFunctionName(functionName)

Set the name of the function to call. The script will be run as global script if no function name is set.

Parameters:
NameTypeDescription
functionNamestring

Name of the function to call

setParameters(parameters)

Sets the parameters passed to the script. If a function is specified, then the parameters are passed as the first argument. If no function is specified, then the variables will be added to the global context

Parameters:
NameTypeDescription
parametersobject

Parameters object

setPriority(priorityNumber)

Sets the priority of the job. Default priority is 100. The lower the number the higher the priority.

Parameters:
NameTypeDescription
priorityNumberinteger

Priority

Inherited From

setRunInTransaction(runInTransaction)

Set to true if the entire script job should be run in a transaction. If false, then the script must handle transactions.

Parameters:
NameTypeDescription
runInTransactionboolean
Since
  • 5.3.3

setScript(scriptID)

Set the script

Parameters:
NameTypeDescription
scriptIDstring

Registered ID of the script

setUser(User)

Set the user. If not set, the current user will be set on insert(). Note: setting a different user is allowed only if elevatedDo() is allowed in this context, otherwise an access denied exception is thrown

Parameters:
NameTypeDescription
User