The following function can be used to call the NetSuite suitelet from JS attached to the Html page.
/**
* Function is used to process the import file
* @param {*} fileObj object containing the file data
* @param {*} legalEntityvalue legal entity value
* @param {*} versionValue version value
*/
function processImportFile(fileObj, legalEntityvalue, versionValue) {
try {
let u = [‘SuiteletFileLink’] + “&import=true&fileData=” + JSON.stringify(fileObj); //suitelet file link with parameters
let cb = ‘processedImportResponse’; //call back function
getJSONP(u + ‘&callback=’ + cb);
} catch (err) {
console.error(err);
}
}
/**
* for Callback function – Get Request
* @param {*} url suitelet url
*/
function getJSONP(url) {
try {
let script = document.createElement(‘script’);
let head = document.getElementsByTagName(‘head’)[0] || document.documentElement;
script.src = url;
head.appendChild(script);
} catch (err) {
console.error(err);
}
}
/**
* Function is used to process the response after importing the file
* @param {*} data
*/
function processedImportResponse(data) {
try {
//functionality in call back function
} catch (err) {
console.error(err);
}
}