SuiteScript 2.x Workflow Action Script Type

Workflow action scripts allow you to create custom Workflow Actions that are defined on a record in a workflow. Workflow action scripts are useful for performing actions on sublists because sublist fields are not currently available through the Workflow Manager. Workflow action scripts are also useful when you need to create custom actions that execute complex computational logic that is beyond what can be done with the built-in actions.

For information about SuiteFlow workflows, see the following topics:

For information about scripting with workflow action scripts, see Creating and Using Workflow Action Scripts and SuiteScript 2.x Workflow Action Script Entry Points and API.

You can use SuiteCloud Development Framework (SDF) to manage workflow action scripts as part of file-based customization projects. For information about SDF, see SuiteCloud Development Framework. You can use the Copy to Account feature to copy an individual workflow action script to another of your accounts. Each workflow action script page has a clickable Copy to Account option in the upper right corner. For information about Copy to Account, see Copy to Account Overview.

You can use SuiteScript Analysis to learn about when the script was installed and how it performed in the past. For more information, see Analyzing Scripts.

Workflow Action Script Sample

This sample shows how to store a return value from a custom action script into a workflow field. This sample could be used if:

Before using this script, the following must be done:

          /**
 * @NApiVersion 2.x
 * @NScriptType WorkflowActionScript
 */
define([], function() {
    function onAction(scriptContext){
        log.debug({
            title: 'Start Script'
        });
        var newRecord = scriptContext.newRecord;
        var itemCount = newRecord.getLineCount({
            sublistId: 'item'
        });
        log.debug({
            title: 'Item Count', 
            details: itemCount
        });
        for (var i = 0; i < itemCount; i++){
            var quantity = newRecord.getSublistValue({
                sublistId: 'item', 
                fieldId: 'quantity', 
                line: i
            });
            log.debug({
                title: 'Quantity of Item ' + i, 
                details: quantity
            });
            if (quantity === 0){
                return 0;
            }
        }
        log.debug({
            title: 'End Script'
        });
        return 1;
    }
    return {
        onAction: onAction
    }
}); 

        

See the SuiteFlow help topics for additional samples, such as Storing a Return Value from a Custom Action Script in a Workflow Field. Additional samples are also available by searching “workflow action script” on Suite Answers. Note that some samples may be in SuiteScript 1.0.

Related Topics

SuiteScript 2.x Script Types
SuiteScript 2.x Bundle Installation Script Type
SuiteScript 2.x Client Script Type
SuiteScript 2.x Map/Reduce Script Type
SuiteScript 2.x Mass Update Script Type
SuiteScript 2.x Portlet Script Type
SuiteScript 2.x RESTlet Script Type
SuiteScript 2.x Scheduled Script Type
SuiteScript 2.x Suitelet Script Type
SuiteScript 2.x User Event Script Type

General Notices