Add External Library/CDN in SuiteScript

Import a third-party library

Some third-party libraries register as AMD compatible in which case, you can specify a require configuration that sets up the path where the module is found.

For example, you can create a JSON configuration file (JsLibraryConfig.json) containing the following code and save it in the File Cabinet:

{
"baseUrl": "./",
"paths": {
"jszip": "/SuiteScripts/Libraries/External/jszip",
"xlsx": "/SuiteScripts/Jobin and Jismi IT Services LLP/Read Excel FIle/EXCEL"
}
}

CDN link for xlsx : https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js

In Suitescript call the module path to the json file in NetSuite.

/**
* @NApiVersion 2.1
* @NModuleScope Public
* @NScriptType ScheduledScript
* @NAmdConfig /SuiteScripts/Jobin and Jismi IT Services LLP/Read Excel FIle/nse_sc_excel_sample_conf.json
*
* @module N/search
* @module N/file
* @module xlsx
*
* @description Convert Excel file to json
*/

define(['N/search', 'N/file', 'xlsx'],
function (search, file, XLSX) {

Write the code below and can access to the library.

Leave a comment

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