workflow.initiate(options)
Method Description |
Initiates a workflow on-demand. This method is the programmatic equivalent of the Initiate Workflow Action action in SuiteFlow. Returns the internal ID of the workflow instance used to track the workflow against the record. To asynchronously initiate a workflow, see task.WorkflowTriggerTask. |
Returns |
number |
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types |
Governance |
20 units |
Module |
|
Since |
2015.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
Object |
optional |
The object that contains key-value pairs to set default values on fields specific to the workflow. These can include fields on the Workflow Definition Page or workflow and state Workflow Custom Fields. |
2015.2 |
|
string | number |
required |
The internal ID of the base record. |
2015.2 |
|
string |
required |
The record type ID of the workflow base record. Use values from the record.Type enum. This is the Record Type field on the Workflow Definition Page. |
2015.2 |
|
string | number |
required |
The internal ID (number) or script ID (string) for the workflow definition. This is the ID field on the Workflow Definition Page. |
2015.2 |
Syntax
The following code snippet shows the syntax for this member. It is not a functional example. For a complete script example, see N/workflow Module Script Sample.
//Add additional code
...
var workflowInstanceId = workflow.initiate({
recordType: 'customer',
recordId: 24,
workflowId: 'customworkflow_myWorkFlow'
});
...
//Add additional code