SuiteScript 2.x Bundle Installation Script Type

Bundle installation scripts are specialized server scripts that perform processes in target accounts as part of a bundle installation, update, or uninstallation. These processes include setup, configuration, and data management tasks that would otherwise have to be completed by account administrators.

Every bundle can include a bundle installation script that is automatically run when the bundle is installed, updated, or uninstalled. Each bundle installation script can contain triggers to be executed before install, after install, before update, after update, and after uninstallation.

Bundle installation scripts have no audience because they are always executed using the Administrator role, in the context of bundle installation, update, or uninstallation. Bundle installation scripts do not have event types.

A bundle installation script can be associated with multiple bundles. Before a script can be associated with a bundle, it must have a script record and at least one deployment. A bundle creator associates a bundle installation script with a bundle by selecting one of its deployments in the Bundle Builder. The script .js file and script record are automatically included in the bundle when it is added to target accounts. Script file contents can be hidden from target accounts based on an option set for the .js file in the File Cabinet record.

Bundle installation script failures terminate bundle installations, updates, or uninstallations. Bundle installation scripts can include their own error handling in addition to errors thrown by SuiteBundler and SuiteScript. An error thrown by a bundle installation script returns an error code of Installation Error followed by the text defined by the script author. For information about scripting with bundle installation scripts, see SuiteScript 2.x Bundle Installation Script Entry Points.

For more information about bundle installation scripts, see Using Bundle Installation Scripts and Bundle Support Across Account Types.

Note:

Custom modules are not supported in bundle installation scripts.

You can use SuiteCloud Development Framework (SDF) to manage bundle installation 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 bundle installation script to another of your accounts. Each bundle installation 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.

Bundle Installation Script Sample

The script sample performs the following tasks:

This script sample uses SuiteScript 2.0. A newer version, SuiteScript 2.1, is also available and supports new language features that are included in the ES2019 specification. You can write bundle installation scripts using either SuiteScript 2.0 or SuiteScript 2.1.

          /**
 * @NApiVersion 2.x
 * @NScriptType BundleInstallationScript
 */
define(['N/runtime'], function(runtime) {
    function checkPrerequisites() {
        if (!runtime.isFeatureInEffect({
                feature: 'TIMEOFFMANAGEMENT'
            }))
            throw 'The TIMEOFFMANAGEMENT feature must be enabled. ' +
                'Please enable the feature and try again.';
    }
    return {
        beforeInstall: function beforeInstall(params) {
            checkPrerequisites();
        },
        beforeUpdate: function beforeUpdate(params) {
            checkPrerequisites();
        }
    };
}); 

        

Related Topics

General Notices