Bundle Themes And Extensions as SuiteApps

Step 1: Prepare themes and extensions for bundling

  1. In your NetSuite File Cabinet, navigate to the folder containing your theme or extension. This folder is the one containing your theme and extension files, including the manifest.json file. For example: SuiteScript/Deploy_Extensions/<VendorName>/<ThemeOrExtensionName>@<Version>/
  2. Click edit next to the extension folder you are including in the bundle. In the Document Folder record, check the Available for SuiteBundles option.
  3. Click Save.
  4. Repeat this for every theme and extension you want to include in a SuiteApp

Step 2: Create a unique installation script for your theme or extension suite app.

Before bundling your themes or extensions as a SuiteApp, you must complete the following steps:

  1. Create an Installation script file.
  2. Create an Installation Script record.
  3. Deploy your installation script.

A bundle installation script is essential to allow SuiteApp installation, update, and uninstallation processes to run properly. The SuiteCommerce Extension Management SuiteApp comes with a default bundle installation script that you can use, titled: ExtensionBundle.js. As a best practice, copy the default file to create a unique script for each SuiteApp you want to build.

TO CREATE AN INSTALLATION SCRIPT FILE:

  1. In the NetSuite File Cabinet, browse to SuiteBundles/Bundle xxxxxx, where xxxxxx equals the Bundle ID of the SuiteCommerce Extension Management SuiteApp.
  2. Make a copy of the default ExtensionBundle.js file
  3. Create Installation Script Record
  4. Deploy Script

Step 3: Create the suite app for your themes or extensions

Observe the following information when building a SuiteApp for SuiteCommerce themes and extensions:

  • When choosing the installation script, select the script you created earlier.
  • You cannot use the same Installation Script record across multiple SuiteApps when bundling SuiteCommerce themes or extensions. You must select a unique Installation Script record for each SuiteApp.
  • When prompted to select objects for the SuiteApp, browse to File Cabinet/Folders and choose the objects associated with each theme or extension you are including in your SuiteApp. Look for the objects that match your deployed themes and extensions.
  • You can create theme and extension SuiteApps as managed or unmanaged bundles.
  • You can bundle any number of themes and extensions within one SuiteApp.

NOTE:  If the NetSuite account does not have Extension management bundle installed in it, then you need not bundle the extension with bundle installation script, this will lead into error on installation

/*jshint funcscope:true*/
/*exported beforeInstall*/
/*exported afterInstall*/
/*exported afterUpdate*/
/*exported beforeUninstall*/
/* jshint evil:true */

function beforeInstall()
{
	try
	{
		var config = nlapiLoadConfiguration('companypreferences');
		var path = config && config.getFieldValue('custscript_sc_extmech_api_path');
		var file = path && nlapiLoadFile(path);
	}
	catch(error){}
	
	if (!config || !path || !file)
	{
		throw nlapiCreateError('SCE_EXTMECH_ERROR', 'The Extension Management Bundle it\'s not installed or not configured correctly');
	}
}

function afterInstall()
{
	var config = nlapiLoadConfiguration('companypreferences');
	var path = config && config.getFieldValue('custscript_sc_extmech_api_path');
	
	if (path)
	{
		var file = nlapiLoadFile(path);
		eval(file.getValue());

		SCExtension.afterInstall();
	}
	else
	{
		throw nlapiCreateError('SCE_EXTMECH_ERROR', 'The Extension Management Bundle it\'s not installed or not configured correctly');
	}
}

function afterUpdate()
{
	var config = nlapiLoadConfiguration('companypreferences');
	var path = config && config.getFieldValue('custscript_sc_extmech_api_path');
	
	if (path)
	{
		var file = nlapiLoadFile(path);
		eval(file.getValue());

		SCExtension.afterUpdate();
	}
	else
	{
		throw nlapiCreateError('SCE_EXTMECH_ERROR', 'The Extension Management Bundle it\'s not installed or not configured correctly');
	}
}

function beforeUninstall()
{
	var config = nlapiLoadConfiguration('companypreferences');
	var path = config && config.getFieldValue('custscript_sc_extmech_api_path');
	
	if (path)
	{
		var file = nlapiLoadFile(path);
		eval(file.getValue());

		SCExtension.beforeUninstall();
	}
	else
	{
		throw nlapiCreateError('SCE_EXTMECH_ERROR', 'The Extension Mechanism Bundle it\'s not installed or not configured correctly');
	}
}

Leave a comment

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