createTask()
Overview
public string function createTask(
required string event
, struct args
, string adminOwner = ""
, string webOwner = ""
, boolean runNow = false
, timespan runIn
, boolean discardOnComplete = false
, any discardAfterInterval
, any retryInterval
, string title = ""
, array titleData
, string resultUrl = ""
, string returnUrl = ""
, string reference = ""
, boolean disableCancel = false
)
Registers a new task, optionally running it there and then in a background thread
Arguments
Name | Type | Required | Description |
---|---|---|---|
event | string | Yes | Coldbox event that will be run |
args | struct | No | Args struct to pass to the coldbox event |
adminOwner | string | No (default="") | Optional admin user ID, owner of the task |
webOwner | string | No (default="") | Optional website user ID, owner of the task |
runNow | boolean | No (default=false) | Whether or not to immediately run the task in a background thread. **Note:** If neither `runNow` or `runIn` is set, you will be responsible for running the task yourself with runTask(). |
runIn | timespan | No | Optional *timespan* (`CreateTimeSpan()`) to delay the execution of this task (will only be used if `runNow` is `false`). **Note:** If neither `runNow` or `runIn` is set, you will be responsible for running the task yourself with runTask(). |
discardOnComplete | boolean | No (default=false) | Whether or not to discard the task once completed or permanently failed. Defaults to `false` |
discardAfterInterval | any | No | Interval from completion after which the task will be deleted. Defaults to 1 day. Only used when `discardOnComplete` is set to `false` (default). |
retryInterval | any | No | Definition of retry attempts for tasks that fail to run. Either a single struct, or array of structs with the following keys: `tries`: number of attempts, `interval`:number in seconds between tries (can also use CreateTimeSpan()). For example: `[ { tries:3, interval=CreateTimeSpan( 0, 0, 5, 0 ) }, { tries:2, interval=3600 }]` will retry three times with 5 minutes between attempts and then retry a further two times with 60 minutes between attempts. |
title | string | No (default="") | Optional title of the task, can be an i18n resource URI for later translation. This will be used in any task progress UIs, etc. |
titleData | array | No | Optional array of strings that will be passed into translateResource() along with title URI to create translatable title |
resultUrl | string | No (default="") | Optional URL at which the result of this task can be viewed / downloaded. The token, `{taskId}`, within the URL will be replaced with the actual ID of the task |
returnUrl | string | No (default="") | Optional URL to which to direct users from core admin UIs when they have finished with viewing a task |
reference | string | No (default="") | Optional string with which to provide a key reference for your task |
disableCancel | boolean | No (default=false) | Optional disable cancellation of the task |