We have a few 1.0 scripts in our account still han...
# suitescript
a
We have a few 1.0 scripts in our account still hanging out; suddenly today, a normally working 1.0 client script which calls a (2.0) Suitelet is erroring out. The error seems to be that intermittently (?) the nlapiRequestURL function is sending the params as like “param1=blah&param2=blah”, instead of as an object {“param1”:”blah”, “param2”:”blah”}. Or at least that’s what I can tell from the logs. Just curious if anyone else is running into an issue today with suitelet calls/1.0 scripts, in case it helps me troubleshoot or helps with a NS support case. I suspect this is a hot fix Thursday issue but given it’s 1.0, they may tell me tough luck 🙃
a
it sounds like maybe the difference between a GET and POST to the suitelet that would explain the intermittent nature at least but it could be 100 other things too... so good luck 🙂
f
Just update your 1.0 scripts using gpt.
👀 1
🙄 1
a
When you are communicating with a Suitelet written in 2.0 from a script written in SuiteScript 1.0 and you use the
POST
method, you must specify the type of data you are going to be receiving back via the header or it may fail:
Copy code
var oHeaders = {
    'Content-type': 'application/json'
};
nlapiRequestURL(sSLURL, JSON.stringify(oRequestData), oHeaders, 'POST');
a
thanks all, your ideas helped me get a fix! much appreciated as it was impacting users saving transactions. yes, we should definitely rewrite them in 2.x but for various reasons that’s not an option at the moment. I realized the “intermittent” appearance was because there are also some 2.0 client scripts which call the same suitelet and those are working fine, but it is erroring on every call from the 1.0 script (so not really intermittent). The current nlapiRequestURL (which was working up until today) was only sending the URL & data object, not using any other arguments to specify headers or request method (it was written about a decade ago, and not by me lol). I tried with both and neither seemed to help (specifying POST and/or the content-type in the headers), still experienced the same issue. however when testing that out I realized that the 2.0 suitelet can access context.request.parameters, in which my params are a mostly formatted object (as opposed to the context.request.body which would list them as just a string when coming from a 1.0 script). still doing some testing but I think that may suffice for now (as a stopgap until we can eventually rewrite them, or if NS support decides it counts as a 2.0 bug since it’s technically in the 2.0 suitelet and fixes it).
🙌 1