Mass Update Script in NetSuite to Load and Save Records

Mass updates in NetSuite allow administrators to process large volumes of records efficiently. If you need to load and save records without making any modifications, a simple Mass Update script like the one below can accomplish the task. This can be useful for scenarios where records need to be re-validated, reprocessed, or updated indirectly by triggering workflow actions or User Event scripts.

Mass Update Script Code:

define([‘N/record’],

/**

 * @param{record} record

 */

    (record) => {

        /**

         * Defines the Mass Update trigger point.

         * @param {Object} params

         * @param {string} params.type – Record type of the record being processed

         * @param {number} params.id – ID of the record being processed

         * @since 2016.1

         */

        const each = (params) => {

            try {

                let newRec = record.load({

                    type: params.type,

                    id: params.id,

                    isdynamic: true

                });

                newRec.save();

                // log.debug(“Record ID”, newRec.id); // Uncomment if you want to display the Id of the records being updated.

            }

            catch (e) {

                log.error(“Error @ each”, e);

            }

        }

        return { each }

    });

Key Script Components

  1. record.load(): Loads the record dynamically based on the record type and ID.
  • The isdynamic: true property allows for dynamic manipulation of the record.
  1. newRec.save(): Saves the record without making any changes, ensuring that triggers such as workflows, User Event scripts, and validations are executed.
  2. Error Handling: The try-catch block ensures any issues during the mass update are logged, helping identify errors without halting the entire process.
  3. Logging (Optional): Use log.debug() to verify which records are processed if needed for debugging.

Use Cases for this Script

  1. Triggering Workflows: Automatically execute workflows that run on record creation or editing by simply saving the record.
  2. Revalidating Data: Reapply any existing business rules or calculations defined in User Event scripts.
  3. Refreshing Records: Ensure that data in the system is updated to reflect the latest logic or rules.

This Mass Update script is a simple yet powerful tool for processing records in bulk. Whether you need to refresh data, trigger backend processes, or execute workflows, this script provides an efficient way to achieve your goal. By leveraging NetSuite’s Mass Update functionality, you can keep your records up-to-date with minimal manual effort.

Leave a comment

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