nathanw
05/16/2024, 3:43 PM/**
* @NApiVersion 2.x
* @NScriptType Suitelet
*/
define(["N/search", "N/render", "N/record"], function (search, render, record) {
"use strict";
function onRequest(context) {
log.debug("Hello", "World");
if (context) {
log.debug("context", "exists");
}
if (context.request) {
log.debug("context.request", context.request);
}
}
return {
onRequest: onRequest,
};
});
Why do I get the error:
"error": { "code": "JS_EXCEPTION", "message": "org.mozilla.javascript.EcmaError: TypeError: Expected argument of type object, but instead had type string (/SuiteScripts/script.js#14)" }
Thread in Slack Conversationnathanw
05/16/2024, 3:44 PMClay Roper
05/16/2024, 3:47 PMClay Roper
05/16/2024, 3:49 PMerictgrubaugh
05/16/2024, 3:53 PMuse strict
in SuiteScript? What does it change about the NetSuite runtime? Is this a holdover from the browser? What am I missing?erictgrubaugh
05/16/2024, 3:53 PMnathanw
05/16/2024, 3:55 PMfunction onRequest(context) {
log.debug("Hello", "World");
if (context) {
log.debug("context", "exists");
log.debug({
title: "context",
details: JSON.stringify(context)
});
}
}
erictgrubaugh
05/16/2024, 3:55 PMerictgrubaugh
05/16/2024, 3:55 PMnathanw
05/16/2024, 3:56 PMerictgrubaugh
05/16/2024, 3:56 PMClay Roper
05/16/2024, 3:56 PMClay Roper
05/16/2024, 3:56 PMlog.debug("context.request", context.request);
erictgrubaugh
05/16/2024, 3:57 PMClay Roper
05/16/2024, 3:59 PMerictgrubaugh
05/16/2024, 3:59 PMerictgrubaugh
05/16/2024, 4:00 PMClay Roper
05/16/2024, 4:00 PMnathanw
05/16/2024, 4:02 PMerictgrubaugh
05/16/2024, 4:03 PMnathanw
05/16/2024, 4:04 PMClay Roper
05/16/2024, 4:05 PMalien4u
05/16/2024, 4:27 PMdetails
is overloaded but title
is not, therefore trying to use context
which is an object in the title
is what is causing this problem.erictgrubaugh
05/16/2024, 4:28 PMtitle
?alien4u
05/16/2024, 4:28 PMalien4u
05/16/2024, 4:28 PMerictgrubaugh
05/16/2024, 4:29 PMerictgrubaugh
05/16/2024, 4:30 PMlog
module on the client side. This is how the overload works:alien4u
05/16/2024, 4:32 PM""
you are right @erictgrubaugh
Then it must be this: "use strict";
nathanw
05/16/2024, 4:45 PM"use strict"
nathanw
05/16/2024, 4:48 PMClay Roper
05/16/2024, 4:49 PMnathanw
05/16/2024, 4:53 PMClay Roper
05/16/2024, 4:53 PMShawn Talbert
05/16/2024, 5:01 PMerictgrubaugh
05/16/2024, 5:06 PMnathanw
05/16/2024, 5:07 PMnathanw
05/16/2024, 5:07 PMClay Roper
05/16/2024, 5:09 PMnathanw
05/16/2024, 5:11 PMalien4u
05/16/2024, 5:16 PMnathanw
05/16/2024, 5:18 PMalien4u
05/16/2024, 5:19 PMalien4u
05/16/2024, 5:20 PM