workflow.initiate(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

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

N/workflow Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.defaultValues

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

options.recordId

string | number

required

The internal ID of the base record.

2015.2

options.recordType

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

options.workflowId

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
Important:

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 

        

Related Topics

N/workflow Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices