SuiteScript 2.x Mass Update Script Type

Mass update scripts allow you to programmatically perform custom updates to fields that are not available through general mass updates. Mass update scripts can run complex calculations, as defined in your script, across records. Mass update scripts are started on demand, and you cannot prioritize them or schedule them to run at specific times. If you want your script to run at a specific time, consider using a scheduled script or map/reduce script instead of a mass update script. For more information, see SuiteScript 2.x Scheduled Script Type and SuiteScript 2.x Map/Reduce Script Type.

Mass update scripts are executed on the server when you click the Perform Update button on the Mass Update Preview Results page. You cannot invoke a mass update script from another script type. You also cannot programmatically check the status of a mass update script or determine when the script started or ended.

Important:

The following items should be considered when running a mass update script:

  • Updates made to records during a custom mass update can trigger user event scripts if there are user event scripts associated with the records being updated.

  • Mass update script deployments and mass updates can both be assigned an audience. It is the script owner's responsibility to ensure the two audiences are in sync. If the two audiences do not match, the mass update script will not run when users click the Perform Update button on the Mass Update page.

  • When users run custom mass updates, they must have the appropriate permission (Edit/Full) for the record type(s) they are updating.

  • Users must also have SuiteScript enabled in their accounts. (Administrators can go to Setup > Company > Enable Features. In the SuiteCloud tab, click the Server SuiteScript box and the Client SuiteScript box.)

For information about scripting with mass update scripts, see SuiteScript 2.x Mass Update Script Entry Points.

You can use SuiteCloud Development Framework (SDF) to manage mass update 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 mass update script to another of your accounts. Each mass update script page has a clickable Copy to Account option in the upper right corner. For information about Copy to Account, see Copy to Account.

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.

Mass Update Script Sample

The following code updates the probability field of all existing records to 61%.

Note:

From the script deployment record, ensure that the Applies To field is set to Opportunity.

For help with writing scripts in SuiteScript 2.x, see SuiteScript 2.x Hello World and SuiteScript 2.x Entry Point Script Creation and Deployment.

          /**
 *@NApiVersion 2.1
 *@NScriptType MassUpdateScript
 */
define(['N/record'], (record) => {
    function each(params) {
        // Set the probability to 61%
        let recOpportunity = record.load({
            type: params.type,
            id: params.id
        });
        recOpportunity.setValue('probability', 61);
        recOpportunity.save();
    }
    return {
        each: each
    };
}); 

        

Related Support Article

Related Topics

General Notices