Bundle Installation Script
Hi Reader,
Netsuite provide many features which can be enabled/disabled using preference.
Most of the time when user install a bundle features is enabled but sometimes
because of disabled preference Bundle throw error and cause lot of pain for
company who uses it as well as who created it. This gives Netsuite to develop
new type of script called as Bundle Installation script.
Bundle installation script is server side script which perform process in account where it is installed.
This script helps while installation, update or uninstall of a bundle.These script can setup, validate,
configure Netsuite account. This script help account administrators for their job.
Every bundle can include a bundle installation script that is automatically run when the bundle is installed,
upgraded, or uninstalled. Each bundle installation script can contain triggers to be executed before install,
after install, before update, after update, and before uninstall.
Bundle Installation Script Entry Points
1. beforeInstall: Executes before a bundle is installed for the first time in a target account.
2. afterInstall : Executes after a bundle is installed for the first time in a target account.
3. beforeUpdate : Executes before a bundle in a target account is updated.
4. afterUpdate : Executes after a bundle in a target account is updated.
5. beforeUninstall : Executes before a bundle is uninstalled from a target account.
Bundle installation scripts can include their own error handling in addition to errors thrown by SuiteBundler
and the SuiteScript engine. An error thrown by a bundle installation script returns an error code of Installation
Error followed by the text defined by the script author
** Follow same step as explained in other script type. Adding Screenshot of script for reference.
Example: Lets say bundle you develop is using accounting period, you want to validate of Accounting periods feature is already enabled or not. Bundle Installation Script will run when someone try to install
bundle in system and validate if Accounting Periods feature is enabled or not , else give error.
/**
* @NApiVersion 2.0
* @NScriptType BundleInstallationScript
*/
define(['N/runtime'], function(runtime) {
function ngPreCheck() {
if (!runtime.isFeatureInEffect({
feature: 'ACCOUNTINGPERIODS'
}))
throw 'The ACCOUNTINGPERIODS feature must be enabled. ' +
'Please enable the feature and try again.';
}
return {
beforeInstall: ngPreCheck,
beforeUpdate: ngPreCheck;
}
};
});
Thanks
Netsuite Guru
Download Netsuite Guru Android App
Follow Me on Linkedin
Our FB Page
Netsuite provide many features which can be enabled/disabled using preference.
Most of the time when user install a bundle features is enabled but sometimes
because of disabled preference Bundle throw error and cause lot of pain for
company who uses it as well as who created it. This gives Netsuite to develop
new type of script called as Bundle Installation script.
Bundle installation script is server side script which perform process in account where it is installed.
This script helps while installation, update or uninstall of a bundle.These script can setup, validate,
configure Netsuite account. This script help account administrators for their job.
Every bundle can include a bundle installation script that is automatically run when the bundle is installed,
upgraded, or uninstalled. Each bundle installation script can contain triggers to be executed before install,
after install, before update, after update, and before uninstall.
Bundle Installation Script Entry Points
1. beforeInstall: Executes before a bundle is installed for the first time in a target account.
2. afterInstall : Executes after a bundle is installed for the first time in a target account.
3. beforeUpdate : Executes before a bundle in a target account is updated.
4. afterUpdate : Executes after a bundle in a target account is updated.
5. beforeUninstall : Executes before a bundle is uninstalled from a target account.
Bundle installation scripts can include their own error handling in addition to errors thrown by SuiteBundler
and the SuiteScript engine. An error thrown by a bundle installation script returns an error code of Installation
Error followed by the text defined by the script author
** Follow same step as explained in other script type. Adding Screenshot of script for reference.
Bundle Installation Script |
bundle in system and validate if Accounting Periods feature is enabled or not , else give error.
/**
* @NApiVersion 2.0
* @NScriptType BundleInstallationScript
*/
define(['N/runtime'], function(runtime) {
function ngPreCheck() {
if (!runtime.isFeatureInEffect({
feature: 'ACCOUNTINGPERIODS'
}))
throw 'The ACCOUNTINGPERIODS feature must be enabled. ' +
'Please enable the feature and try again.';
}
return {
beforeInstall: ngPreCheck,
beforeUpdate: ngPreCheck;
}
};
});
Thanks
Netsuite Guru
Download Netsuite Guru Android App
Follow Me on Linkedin
Our FB Page
This comment has been removed by a blog administrator.
ReplyDelete