NetSuite SheetJS Error #3097

Open
opened 2024-03-28 10:29:06 +00:00 by suitesparkle · 4 comments

NetSuite is having troubles with SheetJS. When we save the script file, we get the following error message: Fail to evaluate script: com.netsuite.suitescript.scriptobject.GraalValueAdapter@68d0f09d

When this was raised with Oracle, we were informed that this issue is caused by xlsx being a reserved word in NetSuite SuiteScript hence the error. When in the Script config file we rename xlsx to XLSX or xlsx2 or anything different, the script saves without problems, however the library does not get loaded properly and none of the sheetJS tools work returning TypeError: Cannot read property 'utils' of undefined.

As Oracle is not going to do anything with this, is there an option to change the reference from xlsx to something else on sheetJS end?

The error happens after every maintance of NetSuite or upgrade lasts for months, resolve itself and after the next maintance of NS happens again.

NetSuite is having troubles with SheetJS. When we save the script file, we get the following error message: Fail to evaluate script: com.netsuite.suitescript.scriptobject.GraalValueAdapter@68d0f09d When this was raised with Oracle, we were informed that this issue is caused by xlsx being a reserved word in NetSuite SuiteScript hence the error. When in the Script config file we rename xlsx to XLSX or xlsx2 or anything different, the script saves without problems, however the library does not get loaded properly and none of the sheetJS tools work returning TypeError: Cannot read property 'utils' of undefined. As Oracle is not going to do anything with this, is there an option to change the reference from xlsx to something else on sheetJS end? The error happens after every maintance of NetSuite or upgrade lasts for months, resolve itself and after the next maintance of NS happens again.
Owner

Given the sheer number of NetSuite users that have used the xlsx name without issue, this is a bizarre issue.

The official NetSuite documentation on reserved words does not mention xlsx as a reserved word.

SuiteScript

The NetSuite example uses the variable XLSX:

/**
* @NApiVersion 2.x
* @NAmdConfig  ./JsLibraryConfig.json
* ... more options ...
*/
define(['N/file', 'xlsx'], function(file, XLSX) { // <-- the parameter is XLSX
  // ... use XLSX here ...
});

The standalone scripts also expose a global variable named XLSX.

It is strongly recommended to use the variable name XLSX

JSON Configuration

The usage of xlsx in the script config is quoted:

{
  "paths": {
    "xlsx": "/SuiteScripts/xlsx.full.min"
  }
}

The AMD export is at the very end of the standalone script. It's easy to change that name, but it will break other loaders including SAP UI5. We'd likely have to introduce a new build.

Next Steps

A new build can be produced, but we need explicit confirmation from Oracle that the name "xlsx" is unsupported. Please send this issue link to the Oracle support team and request for one of their engineers to reach out to us.

Given the sheer number of NetSuite users that have used the `xlsx` name without issue, this is a bizarre issue. The official [NetSuite documentation on reserved words](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_158687368641.html#SuiteScript-Reserved-Words) does not mention `xlsx` as a reserved word. _SuiteScript_ The [NetSuite example](https://docs.sheetjs.com/docs/demos/cloud/netsuite#suitescript-usage) uses the variable `XLSX`: ```js /** * @NApiVersion 2.x * @NAmdConfig ./JsLibraryConfig.json * ... more options ... */ define(['N/file', 'xlsx'], function(file, XLSX) { // <-- the parameter is XLSX // ... use XLSX here ... }); ``` The [standalone scripts](https://docs.sheetjs.com/docs/getting-started/installation/standalone) also expose a global variable named `XLSX`. It is strongly recommended to use the variable name `XLSX` _JSON Configuration_ The usage of `xlsx` in the [script config](https://docs.sheetjs.com/docs/demos/cloud/netsuite#json-configuration) is quoted: ```js { "paths": { "xlsx": "/SuiteScripts/xlsx.full.min" } } ``` The AMD export is at [the very end of the standalone script](https://git.sheetjs.com/sheetjs/sheetjs/src/branch/master/bits/99_footer.js#L6). It's easy to change that name, but it will break other loaders including SAP UI5. We'd likely have to introduce a new build. _Next Steps_ A new build can be produced, but we need explicit confirmation from Oracle that the name `"xlsx"` is unsupported. Please send this issue link to the Oracle support team and request for one of their engineers to reach out to us.
Author

Indeed very bizarre, we have used this without issues as well. only every few months it starts failing and then solves itself again. Oracle's response was never much helpful apart from this side note of reserved words.

I have raised a new issue with them, hoping they will be more clear now and will provide the confirmation in written.

How difficult would it be for us to change the reference in our local sheetJS? We have tried to rename the reference in the config file to:
image
with the reference being the same in our define:
image

but that does not seem to work with the library and XLSX variable is blank.

Indeed very bizarre, we have used this without issues as well. only every few months it starts failing and then solves itself again. Oracle's response was never much helpful apart from this side note of reserved words. I have raised a new issue with them, hoping they will be more clear now and will provide the confirmation in written. How difficult would it be for us to change the reference in our local sheetJS? We have tried to rename the reference in the config file to: ![image](/attachments/6b388ece-ab88-48a2-959c-f12032033fa6) with the reference being the same in our define: ![image](/attachments/c1106c11-24a2-4ca8-9c14-37c5eb15a37c) but that does not seem to work with the library and XLSX variable is blank.
Owner
  1. Fix the script.

If you would like to edit the script directly: search for define( in the xlsx.full.min.js. There is exactly one instance:

define("xlsx",function(){

Edit xlsx.full.min.js and replace define("xlsx", with define("sheetjs",

If you would prefer to build the script directly: Follow https://docs.sheetjs.com/docs/miscellany/contributing to build the script.

Edit bits/99_footer.js line 6 and change the first argument:

else if(typeof define === 'function' && define.amd) define('sheetjs', function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
  1. Edit your JSON configuration to use the new name:
{
  "paths": {
    "sheetjs": "/SuiteScripts/xlsx.full.min"
  }
}
  1. change the name in the dependencies array:
define(['N/file', ..., 'sheetjs'], ...
1) Fix the script. **If you would like to edit the script directly**: search for `define(` in the `xlsx.full.min.js`. There is exactly one instance: ```js define("xlsx",function(){ ``` Edit `xlsx.full.min.js` and replace `define("xlsx",` with `define("sheetjs",` **If you would prefer to build the script directly**: Follow https://docs.sheetjs.com/docs/miscellany/contributing to build the script. Edit [`bits/99_footer.js` line 6](https://git.sheetjs.com/sheetjs/sheetjs/src/branch/master/bits/99_footer.js#L6) and change the first argument: ```js else if(typeof define === 'function' && define.amd) define('sheetjs', function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; }); ``` 2) Edit your JSON configuration to use the new name: ```json { "paths": { "sheetjs": "/SuiteScripts/xlsx.full.min" } } ``` 3) change the name in the dependencies array: ```js define(['N/file', ..., 'sheetjs'], ... ```
Author

that seemed to have worked! thanks for the help. I have left the ticket with Oracle open, in case we get a clarification of the issue from their end.

that seemed to have worked! thanks for the help. I have left the ticket with Oracle open, in case we get a clarification of the issue from their end.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#3097
No description provided.