Skip to content

Initiate

Initiates a new instance using the specified arguments.

1
myWorkItem.Initiate(inputData: ( string | Xml ), process?: string, options?: InitiateOptions):WorkItem

Parameters

( string | Xml ) inputData
    The input data to pass to the new workflow instance, as an XML string or XML object.

string process optional
    Specifies the process of the new instance. Can be the name or ID of the process. If not specified, the current process is used.

InitiateOptions options optional
    Specifies the options for the new instance.

Returns

The first work item of the initiated workflow in the Created or Waiting state.

Remarks

The new instance is a child of the current work item unless Parent is specified. Its culture and test mode are taken from the parent instance when they are not specified.

Examples

Start a process with XML data

1
2
var data = '<Request><Employee>Jane Doe</Employee><Days>3</Days></Request>';
var child = $WorkItem.Initiate(data, 'Leave Request');

Start a process with a node of the current data

1
2
3
4
5
var child = $WorkItem.Initiate($Xml.SelectSingle('Request'), 'Purchase Request', {
    Task : 'Purchase Request Form'
});

$Xml.SetValue('PurchaseWorkItemId', child.Id);

Start a process on behalf of a user

1
2
3
4
5
var child = $WorkItem.Initiate($Xml.SelectSingle('Request'), 'Purchase Request', {
    Task : 'Purchase Request Form',
    Initiator : $Xml.Evaluate('Requester/Id'),
    Culture : 'en-US'
});

See Also