Constructor
new $k.ScriptJob()
Extends
Methods
(static) cancelSchedule(name)
Cancel a job schedule
| Name | Type | Description | 
|---|---|---|
name | string | 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
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
name | string | The schedule name  | ||
interval | number | The interval in minutes  | ||
user | $k. | The user or user instance  | ||
scriptName | string | The script name  | ||
functionName | string | <optional> | The function name. The script will be run as global script if no function name is set.  | |
runInTransaction | boolean | <optional> | false | Set to true if the entire script job should be run in a transaction. If false, then the script must handle transactions.  | 
- Version
 - Experimental feature, might be removed at any time
 
- Since
 - 5.5.0
 
If the user is not allowed
If the schedule name is already in use
- Type
 - JSERangeError
 
insert()
Add the job to the job queue
- Overrides
 
If the script is not set or the user cannot be determined
setFailureFunctionName(functionName)
Set the name of the function to call when the script job fails.
| Name | Type | Description | 
|---|---|---|
functionName | string | 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.
| Name | Type | Description | 
|---|---|---|
functionName | string | 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
| Name | Type | Description | 
|---|---|---|
parameters | object | Parameters object  | 
setPriority(priorityNumber)
Sets the priority of the job. Default priority is 100. The lower the number the higher the priority.
| Name | Type | Description | 
|---|---|---|
priorityNumber | number | 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.
| Name | Type | Description | 
|---|---|---|
runInTransaction | boolean | 
- Since
 - 5.3.3
 
setScript(scriptID)
Set the script
| Name | Type | Description | 
|---|---|---|
scriptID | string | 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.
| Name | Type | Description | 
|---|---|---|
user | $k. | User or user instance  | 
If the user is not allowed