N/workflow Module

Member TypeNameReturn Type / Value TypeSupported Script TypesDescription
Methodworkflow.initiate(options)numberServer scriptsInitiates 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.
workflow.trigger(options)numberServer scriptsTriggers 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.
Method DescriptionInitiates 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.
Returnsnumber
Supported Script TypesServer scriptsFor more information,
Governance20 units
ParameterTypeRequired / OptionalDescription
options.defaultValuesObjectoptionalThe 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.
options.recordIdstring | numberrequiredThe internal ID of the base record.
options.recordTypestringrequiredThe 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.
options.workflowIdstring | numberrequiredThe internal ID (number) or script ID (string) for the workflow definition. This is the ID field on the Workflow Definition Page.
/**
 * @NApiVersion 2.x
 */

require(['N/workflow', 'N/search', 'N/error', 'N/record'],
    function(workflow, search, error, record) {
        function initiateWorkflow() {
            var workflowInstanceId = workflow.initiate({
                recordType: 'customer',
                recordId: 24,
                workflowId: 'customworkflow_myWorkFlow'
            });
            var customerRecord = record.load({
                type: record.Type.CUSTOMER,
                id: 24
            });
        }
        initiateWorkflow();
    });

Leave a comment

Your email address will not be published. Required fields are marked *