(info) This AI is still in early stages of development.

instance.addTask()

Adds a new task to a process instance.

 

Syntax

Processes("myProcess").addTask(task, taskName, scope);

Parameters

ParameterTypeMandatoryNotesPulse Version
task

Task

Array of Tasks

(tick)

The task, or an array of tasks.

If an array of tasks is used, each task in the array will be added in sequence with the other parameters applied to it. The taskName for each task will be appended with the array index (see below).

0.1
taskNameString(error)

Optionally specify a name for the task(s).

If no name is specified, the function name will be used if possible, otherwise the name will default to "AnonymousTask".

If an array of tasks was passed in on the 'task' parameter, each task will be given a name in the form: "taskName_i" where "i" is the index of the task in the array.

It's recommended to always name your tasks (or make sure they are named functions) to aid with diagnostics.

0.1
scopeObject(error)

Optionally specify an object scope in which the task(s) should be run.

This is ideal for scripts that use OOP as you can run the task(s) as if it were a method on some object.

Defaults to global scope.

0.1

Return value

ValueTypeNotesPulse Version
<instance>Process Instance

The process instance to which the task is added is returned, so you can chain more instance methods, eg:

trigger.addTask(...).addTask(...).run();
0.1
<error>ErrorIf invalid parameters are passed to .addTask(), an error will be thrown.Planned for 0.2

Examples

 

Availability

Requires:

  • Warzone 3.1 or above
  • Process 0.1 or above

Some changes are planned to the return value in Process v0.2.

See also

Essential reading:

  • Tasks – how to define them
  • Process Instances – everything you wanted to know about process instances

Â