ScheduleManagedTask (open)
Schedule a managed task if this transaction commits
Syntax
LOADLIB "mod::system/lib/tasks.whlib";
INTEGER FUNCTION ScheduleManagedTask(STRING tasktype, RECORD taskdata, RECORD options)
Parameters
STRING tasktype
Type of the task to schedule (eq: wrd:deleteschemas) - refers to to the servicemanager:managedtask in the moduledefinition
RECORD taskdata
Task data, as specified by the task. The data must fit in 4K of HSON data
RECORD options
Options
RECORD auxdata
Auxilliary data cells. This will be merged with the task data when passed to the task, but stored separately to avoid the 4K limit
DATETIME notbefore
Scheduled date after which the tasks can be executed
INTEGER taskid
Pre-allocated id of the task to create (must be generated by MakeAutoNumber(system.managedtasks, "ID")
)
INTEGER timeout
Time limit for the task, 0 for no limit. If provided, overrides the limit set with the task type.
Return value
INTEGER
id of this task. This id is a database id and can be used by later scripts
Description
A managed task, once scheduled, will always attempt to complete, and is restarted when it or the task manager fails. Managed tasks are often used for 'after effects' which can take a lot of time, eg the actual deletion of a WRD schema. A managed task will be attempted even if the script that queued it exits before the task starts. If work is open, the task will be queued as soon as the current work is committed, and will not be queued if the work is rolled back.