SuiteScript 2.x Bundle Installation Script Type

Bundle installation scripts are specialized server scripts that perform processes in target accounts when you install, update, or uninstall a bundle. These processes include setup, configuration, and data management tasks that would otherwise have to be done by account administrators.

Every bundle can include a bundle installation script that runs automatically 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.

Unlike other types of SuiteScript scripts, bundle installation scripts have no audience – they are always executed using the Administrator role and in the context of bundle installation, update, or uninstallation. Bundle installation scripts don't have event types.

A bundle installation script can be associated with multiple bundles. Before you can associate a script 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 file and script record are automatically included in the bundle when it's added to target accounts. You can hide script file contents from target accounts by setting an option in the File Cabinet record.

If a bundle installation script fails, it stops the bundle installation, update, or uninstallation. Bundle installation scripts can include their own error handling in addition to errors thrown by SuiteBundler and SuiteScript. When a bundle installation script throws an error, it returns an Installation Error code followed by the message defined by the script author. For information about scripting with bundle installation scripts, see SuiteScript 2.x Bundle Installation Script Entry Points and API.

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

Note:

Custom modules aren't 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 a bundle installation script to another of your accounts. Each bundle installation script page has a Copy to Account option in the upper right corner. For information about Copy to Account, see Copy to Account.

You can use SuiteScript Analytics 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

This script sample will make sure that the Time Off Management feature is enabled in the target NetSuiteaccount before a bundle installation or a bundle update. If it isn't enabled, this script will warn the user.

You can write bundle installation scripts using either SuiteScript 2.0 or 2.1. This script sample is written in SuiteScript 2.0. You can update this script to use SuiteScript 2.1 features.

          /**
 * @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(params) {
            checkPrerequisites();
        },
        beforeUpdate: function(params) {
            checkPrerequisites();
        }
    };
}); 

        

Related Topics

General Notices