I have added a custom script on the address form. ...
# suitescript
n
I have added a custom script on the address form. It has page init function. I am getting an error on the sales order when I select the customer : type:"error.SuiteScriptModuleLoaderError Even when I have "return" on the first line in pageInit Any thoughts?
you havent shared enough of the code or error for specifics, but you are likely using a library that does not run serverside
n
It works fine on customer address record.
Copy code
define(['N/currentRecord', 'N/https', 'N/url'],
       function(currentRecord, https, url) {
I am using these 3 modules.
b
i will do my regular emphasis, my answers rarely make sense unless you read the linked documentation
n
I read the documentation and added the if(typeof document == undefined) {return;} in the pageInit.
b
good, keep on reading
n
Ohhhhhhhhhhh
N/currentRecord
I have removed the N/currentRecord module. Still the same error.
"{"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"syntax error (/SuiteScripts/nSolutions/nzr_address_cs.js#36)","stack":["wrapModuleLoaderError(handleV2RecordScripting:3410)","injectScript(handleV2RecordScripting:3532)","<anonymous>(handleV2RecordScripting:3731)","<anonymous>(handleV2RecordScripting:2630)","<anonymous>(handleV2RecordScripting:1781)","<anonymous>(handleV2RecordScripting:1771)","<anonymous>(handleV2RecordScripting:1801)","<anonymous>(handleV2RecordScripting:2104)","<anonymous>(handleV2RecordScripting:2495)","<anonymous>(handleV2RecordScripting:2089)","<anonymous>(handleV2RecordScripting:1072)","each(handleV2RecordScripting:997)","<anonymous>(handleV2RecordScripting:2051)","<anonymous>(handleV2RecordScripting:1735)","<anonymous>(handleV2RecordScripting:2400)","<anonymous>(handleV2RecordScripting:2846)","<anonymous>(handleV2RecordScripting:2847)","localRequire(handleV2RecordScripting:2389)","<anonymous>(N/scriptLoader.js)","<anonymous>(handleV2RecordScripting:2676)","<anonymous>(handleV2RecordScripting:1822)","<anonymous>(handleV2RecordScripting:2104)","<anonymous>(handleV2RecordScripting:1735)","<anonymous>(handleV2RecordScripting:2400)","<anonymous>(handleV2RecordScripting:2846)","<anonymous>(handleV2RecordScripting:2847)","localRequire(handleV2RecordScripting:2389)","entryPointRequire(N/scriptLoader.js)","v2EnhancedCall(NLRecordScripting.scriptInit:5664)","doTriggerScript(NLRecordScripting.scriptInit:5710)","nlapiPageInit(NLRecordScripting.scriptInit:413)","page_init(NLRecordScripting.scriptInit:209)"]}"
b
you are now at the point where you need to share the code
n
OK, I am removing from the code the client-side code such as window.location and alert.
The error has moved from line # 36 to #145: "{"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"missing : after property id (/SuiteScripts/nSolutions/nzr_address_cs.js#146)","stack":["wrapModuleLoaderError(handleV2RecordScripting:3410)","injectScript(handleV2RecordScripting:3532)","anonymous(handleV2RecordScripting:3731)","anonymous(handleV2RecordScripting:2630)","anonymous(handleV2RecordScripting:1781)","anonymous(handleV2RecordScripting:1771)","anonymous(handleV2RecordScripting:1801)","anonymous(handleV2RecordScripting:2104)","anonymous(handleV2RecordScripting:2495)","anonymous(handleV2RecordScripting:2089)","anonymous(handleV2RecordScripting:1072)","each(handleV2RecordScripting:997)","anonymous(handleV2RecordScripting:2051)","anonymous(handleV2RecordScripting:1735)","anonymous(handleV2RecordScripting:2400)","anonymous(handleV2RecordScripting:2846)","anonymous(handleV2RecordScripting:2847)","localRequire(handleV2RecordScripting:2389)","anonymous(N/scriptLoader.js)","anonymous(handleV2RecordScripting:2676)","anonymous(handleV2RecordScripting:1822)","anonymous(handleV2RecordScripting:2104)","anonymous(handleV2RecordScripting:1735)","anonymous(handleV2RecordScripting:2400)","anonymous(handleV2RecordScripting:2846)","anonymous(handleV2RecordScripting:2847)","localRequire(handleV2RecordScripting:2389)","entryPointRequire(N/scriptLoader.js)","v2EnhancedCall(NLRecordScripting.scriptInit:5664)","doTriggerScript(NLRecordScripting.scriptInit:5710)","nlapiPageInit(NLRecordScripting.scriptInit:413)","page_init(NLRecordScripting.scriptInit:209)"]}"
@battk issue seems to have been resolved. It turns out that CS on address record is evaluated with SS 2.0 engine because it threw error on everything we can use in SS 2.1. For example string literal and arrow function