Context Type Examples

Use the following examples for sample workflow definition settings that initiate a workflow instance or execute actions and transitions for a specific context type.

CSV Import

Use the following sample settings to initiate a workflow and execute actions and transitions for a sales order submitted by CSV import:

Task Type

Description

Settings

Workflow initiation

Initiate workflow instance on new sales orders submitted by CSV import.

Trigger On: After Record Submit

On Create: checked

On Update: unchecked

Contexts: CSV Import

Action, Transition

Action or transition executes if sales order submitted by CSV import.

Trigger On: After Record Submit

Contexts: CSV Import

User Event Script

Important:

The User Event script context only works with NetSuite back-end user events such as email

Use the following sample settings to initiate a workflow and execute actions and transitions for a sales order created with the following user event script:

          /**
* @NAPIVersion 2.0
* @NScriptType UserEventScript
*/
define(["N/record"], function (record) {
    function createSalesOrd() {
        var salesOrd = record.create({ type: record.Type.SALES_ORDER, isDynamic: true });
        salesOrd.setValue({ fieldId: 'entity', value: 185 });
        salesOrd.setValue({ fieldId: 'memo', value: 'created through user event' });
        salesOrd.selectNewLine({ sublistId: 'item' });
        salesOrd.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: 42 });
        salesOrd.commitLine({ sublistId: 'item' });
        salesOrd.save();
    }

    return {
        afterSubmit: createSalesOrd
    };
}); 

        

Task Type

Description

Settings

Workflow initiation

Initiate a workflow instance on new sales orders created with a user event script.

Trigger On: After Record Submit

On Create: checked

On Update: unchecked

Context Type: User Event Script

Action, Transition

Action or transition executes on a sales order created with a user event script.

Trigger On: After Record Submit

Context Type: User Event Script

Custom Mass Update

Use the following sample settings to initiate a workflow and execute actions and transitions for a Customer record updated with the following mass update script.

          /**
* @NApiVersion 2.0
* @NScriptType MassUpdateScript
*/
define(["N/record"], function (record) {
    function customerMassUpdate(params) {
        record.submitFields({
            type: params.type,
            id: params.id,
            values: {
                comments: 'Specifying Customer Mass Update context'
            }
        });
    }

    return {
        each: customerMassUpdate
    };
}); 

        

Task Type

Description

Settings

Workflow initiation

Initiate workflow instance on a Customer record updated with a mass update script.

Trigger On: After Record Submit

On Create: checked

On Update: unchecked

Context: Custom Mass Update

Action, Transition

Action or transition executes on a Customer record updated with a mass update script.

Trigger On: After Record Submit

Context Type: Custom Mass Update

Related Topics

General Notices