Quick question. I am currently trying to upgrade a...
# suitescript
f
Quick question. I am currently trying to upgrade all my scripts to SuiteScript 2.1. However after deploying for example my
sublist_server.js
file I get the error
syntax error (/SuiteApps/.../sublist_server.js#20)
Line 17-29 looks like this :
Copy code
const values = apSearch.run().getRange({
      start: 0,
      end: 1000
    }).map(result => ({
      value: result.getValue({
        name: "internalid"
      }),
      text: `${result.getValue({
        name: "number"
      })} - ${result.getValue({
        name: "name"
      })}`
    }));
c
what if text is set to: (result.getValue({name: 'number'} + '-' + result.getValue({name: 'name'}})
f
Hmm I can't easily try that but let me see. I did notice one thing. Even though my entry file Suitelet has
Copy code
/**
 * @NApiVersion 2.1
 * @NScriptType Suitelet
 */
(it used to be
2.x
) the Script record for that file still says API Version
2.0
shouldn't changing the header of the file make Netsuite change that?
I am deploying through sdf
c
It looks like you're setting the value of text to a string value of the variables not what you want. I doubt the script version is going to have any impact on the issue but it may be a separate issue to get the script version corrected.
f
no its a template string
and that would explain why I get a syntax error
if it is not using Suitescript 2.1 but 2.0 to execute the script
c
Could be then. I don't know anything about template strings sorry
try re-creating the script record itself and see if it updates would be what i would try next
f
I might have found something. When re-saving the script inside Netsuite I get
Copy code
Fail to evaluate script: {"type":"error.SuiteScriptError","name":"SUITESCRIPT_API_UNAVAILABLE_IN_DEFINE","message":"All SuiteScript API Modules are unavailable while executing your define callback.","stack":["Error\n at Object.hasSubsidiary (/SuiteApps/.../lib/config_util.js:33:21)\n at /SuiteApps/.../lib/config_api.js:11:38"],"cause":{"type":"internal error","code":"SUITESCRIPT_API_UNAVAILABLE_IN_DEFINE","details":"All SuiteScript API Modules are unavailable while executing your define callback."
never seen that before. I wonder if 2.1 has slightly different rules since in 2.0 that used to work
e
NS API seems to be having issues today...
d
I have gotten that error before, seems 2.1 is more strict, all logic that calls to SS API module has to be tucked away within an entry point function now to pass validation
s
I concur with @dbarnett the 2.1 checker is more strict - and technically flawed imho.
f
Yeah that was the issue. Oh well luckily we didn't do it very often in our code