SuiteScript 2.x Bundle Installation Script Reference
A bundle installation script's functions run automatically during bundle install, update, or uninstall, based on these triggers or entry points::
-
beforeInstall - executed before a bundle is installed for the first time in a target account.
-
afterInstall - executed after a bundle is installed for the first time in a target account.
-
beforeUpdate - executed before a bundle in a target account is updated.
-
afterUpdate - executed after a bundle in a target account is updated.
-
beforeUninstall - executed before a bundle is uninstalled from a target account.
A bundle installation script file should include at least one entry point. If you are using multiple entry points, you should include them in the same script file.
The following are example uses for each entry point:
-
beforeInstall: Check the existing configuration and setup in the target account prior to bundle installation, and halt the installation with an error message if the target account doesn't meet minimum requirements to run the solution.
-
afterInstall: Automate the setup and configuration of the bundled application after it 's been installed in the target account, eliminating manual tasks.
-
afterInstall or afterUpdate: Connect to an external system to fetch data and complete the setup of the bundled application.
-
beforeUpdate: Manage required data changes in the target account prior to executing an upgrade.
-
beforUninstall: Reset configuration settings or remove data associated with the bundle being uninstalled.
Two specialized parameters are available to functions in bundle installation scripts to return the version of bundles as specified on the Bundle Basics page of the Bundle Builder.
-
The toversion parameter returns the version of the bundle that will be installed in the target account. This parameter is available to beforeInstall, afterInstall, beforeUpdate, and afterUpdate entry point functions.
-
The fromversion parameter returns the version of the bundle that's currently installed in the target account. This parameter is available to beforeUpdate and afterUpdate entry point functions.
A bundle installation script file can call functions in other script files, as long as those files are added as library script files on the script record. Any .js library script files are automatically included in the bundle when it's added to target accounts.
Bundle installation scripts can call scheduled scripts, but only in the afterInstall and afterUpdate entry point functions. Calls to scheduled scripts aren't supported in the beforeInstall, beforeUpdate, or beforeUninstall entry points.
Bundle installation scripts have a 10,000 governance unit limit per execution.
You can create multiple deployments for each bundle installation script, each with different parameters, but only one deployment can be associated with each bundle. When you associate a bundle installation script with a bundle, you choose a specific script deployment.
Bundle installation scripts need to be executed with administrator privileges. The Execute as Role field should always be set to Administrator on the script deployment record.
Bundle installation scripts can only be run in target accounts if the Status is set to Released. You can set the Status to Testing if you want to debug the script but it must be set to Released when you are done testing.