2 Questions 1. Is there a way to call a 2.1 script...
# suitescript
s
2 Questions 1. Is there a way to call a 2.1 script from a 2.0 script? I get "failed to evaluate script" when trying to save the 2.0 script 2. Is there a way to upgrade, without deleting, a 2.0 to 2.1?
s
For the second one, just changing the header to 2.1... the scripted record usually picks it up. That used to be broken but seems to work fine for me now
s
I have had instances where it gave me trouble, but changing it from 2.0 to 2.x, then saving it, then changing 2.x to 2.1 worked for me in those instances. Then again, as @Sandii said, maybe it’s no longer an issue.
Just note that some things, like Error throwing/handling, work a little differently between 2.0 and 2.1, and can possibly break some scripts.
s
And if you have any custom utils/libraries that are friendlier syntax wise for 2.0, 2.1 might also break them.
s
Ok @scottvonduhn I'll try that. Yeah @Sandii I have 2.1 library files and I'm trying to use them in a 2.0 user event script
although I think it says 2.x when it was created, and it has it slated as 2.0
s
That's an instance/company setting, what 2.x defaults to.
s
ohhhh, where is that set at?
Found it!
👍 1
Trying to import a lib file into another one and it is giving
Fail to evaluate script: {"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"syntax error (/SuiteScripts/AccentDecor/Libs/ExternalLibs/JSONXML/jsonxml.js#25)","stack":[]}
So a 2.1 script is importing a library js file that imports another library js file. Have y'all seen this before?
Copy code
function jsonxml(obj, options = {}) {}
s
this usually depends on the third party (lib) script support for modules. Most libraries are designed to work in environments like nodejs or the browser, not SuiteScript. Solutions can be to either collapse the library and its dependencies into a single file or adjust how it imports its dependencies so they work in the AMD-ish NS environment.
s
That's what I've done. It's a pretty simple script and I've wrapped it in a define and returned what I needed to return
At the moment, this is my entire 3rd party library
Copy code
define([], function () {
    const jsonxml = (obj, options) => {

    };

    return jsonxml;
});
s
Just a guess, maybe it’s expecting the module to return an object instead of a function? So maybe try
return { jsonxml };
s
Figured out part of the issue. For some reason, calling record.Type is causing SUITESCRIPT_API_UNAVAILABLE_IN_DEFINE","message":"All SuiteScript API Modules are unavailable while executing your
actually, calling that on script iniailization is causing the issue. So I have const recordObj = setupObj(); return {recordObj}