I have a RESTLet written in Suite Script 2.0. Using Suite Script 2.0, I want to use dataset module to access Suite Analytics datsets. I am testing this with my demo NetSuite account and in my account I have Suite Analytics feature so I there is no error while deploying the script on NetSuite as well when calling the its functionliti from my C# code.
Here I have a query what if I try to deploy this script in a NetSuite account that has not Suite Analytics, will NetSuite give an error saying “MODULE_DOES_NOT_EXIST” or it let me deployed the script and will only give the error when I will call some function related to Suite Analytics?
In below sample code, I have created a function to determine if dataset module is available or not however if NetSuite would gives “MODULE_DOES_NOT_EXIST” error while parsing the my .js file then I would not be able to deploy it.
define
(
'N/record'
,'N/search'
,'N/runtime'
,'N/dataset'
,'N/query'
], mainFuncion
);
var dataset;
/********************** MAIN FUNCTION (Entry Point)**********************
function mainFuncion(pRecordMdule, pSearchModule, pRuntimeModule, pDatasetModule, pQueryModule)
{
dataset = pDatasetModule;
var isSuiteAnalyticsAvilable = checkIfSuiteAnalyticsAvilable();
}
//<--Suite Analytics - Dataset changes
function checkIfSuiteAnalyticsAvilable()
{
var isSuiteAnalyticsAvilable = false;
try
{
var isSuiteAnalyticsAvilable = false;
// Attempt to load all datasets
var dsList = dataset.list();
// If no error occurs in above line, SuiteAnalytics is available
isSuiteAnalyticsAvilable = true;
}
catch (ex)
{
// If an error occurs, it might indicate SuiteAnalytics is not available
isSuiteAnalyticsAvilable = false;
log.debug("SuiteAnalytics is not available in this NetSuite account.", e.message);
}
return isSuiteAnalyticsAvilable;
}