workflow.trigger(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Triggers a workflow on a record. The actions and transitions of the workflow are evaluated for the record in the workflow instance, based on the current state for the workflow instance.

Returns the internal ID of the workflow instance used to track the workflow against the record.

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.actionId

string | number

optional

The internal ID of a button that appears on the record in the workflow.

Use this parameter to trigger the workflow as if the specified button were clicked.

2015.2

options.recordId

string

required

The record ID of the workflow 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.stateId

string | number

optional

The internal ID (number) or script ID (string) of the workflow state that contains the action.

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

options.workflowInstanceId

string | number

optional

The internal ID of the workflow instance.

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.trigger({
    recordId: '5', // replace with an actual record id    
    recordType: 'salesorder',
    workflowId: 'custworkflow_name',
    actionId: workflowaction25
});
...
//Add additional code 

        

Related Topics

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

General Notices