but not sure how to achieve the equivalent in Suit...
# suitescript
j
but not sure how to achieve the equivalent in SuiteScript
c
If you don’t throw an error the the response object should have the 200/OK included.
I’ve tried to overwrite and add to the the header array in the response object and NS ignores the changes.
e
Yep, just don't throw an error
Let the Suitelet return normally; I don't think you need to manipulate the response at all
c
what about
context.response.write(’    ');
j
so I guess opposite question is if I wanted to return something other than 200 is that possible?
c
Yep, in your SL just
throw Error('it broke');
or
throw error.create({ … });
j
ok actually not a Suitelet, it’s an .ss (SSP application)
I can call it directly via URL and it’s returning a blank page, which is correct
but my external application doesn’t like it
whereas it’s fine with a PHP url that returns a blank page
so something must be different…
hmmm
e
can you just do something like
response.write({output: ""});
?
j
let me try
I’m thinking the issue is the difference between ‘’ and ' '
doesn’t let it be empty. booooo
ServerResponse.write: Missing a required argument: output"
pretty sure this is the problem
e
Does it matter if it has something in the response body then?
just write "a"
☝🏻 1
j
it needs to be empty
I think
let me test this
e
That seems odd
c
{ output: ' '}
, with a single space? I’ve run into this problem with required fields and get around it with a space.
j
single space breaks it in the PHP one too
looks like it HAS to be completely blank
e
........
c
I have some old SCA code where I set the content type before I could wrote JSON to the output like this:
Copy code
response.setContentType("JSON");
response.write(JSON.stringify(tree));
j
but then you are still writing some output
I’ll try it, who knows.
whee unexpected error
my favourite
on hang on that’s SS1.0
c
Yes, sorry, it’s old code. SSP wasn’t availble in 2.0 back then.
j
no joy. Your code returns ‘{}’ which is also not blank.
I think I might try redirecting to an empty HTML file in the file cabinet
¯\_(ツ)_/¯
I hate NS sometimes
e
This doesn't seem like it has anything to do with NetSuite, and more to do with the calling client
I don't know why you'd ever
require
the body to be empty if you didn't care about what was in it
needs to send back acknowledgement 200 OK right away
and apparently has to be completely blank
b
what error is slack giving you
e
Wild. FWIW this works completely fine:
Copy code
function onRequest(context) {
  log.audit({title: "request received"});
}
b
suitelets tend to be unreliable for webhooks because of HTTP _405_ Method Not Allowed
c
Yes, this is true. Not sure what else to use for a webhook in NS though.
j
I’m actually using a SSP application which does the work of generating OAuth headers and then passes the request on to a Restlet that does the heavy lifting
that all works fine, except I need this very simple request to just get back an empty page with a 200 OK
b
a suitelet that does nothing returns an empty response body with a 200 status code
you may want to look for other causes of your problem, especially user agent if you are doing webhooks
j
I can’t control any of the headers coming from Slack at all
I have no control over anything until it reaches NetSuite
b
you should probably check what headers it sends using a service like https://requestbin.io/
j
this all worked fine in PHP….sigh
b
this personally sounds familiar
i think you tried this before, and i gave the same answer
j
well that was before I got the SSP application up and running
that solved like 99.99% of the integration
I have slack and netsuite successfully talking to each other, with headers being generated by the SSP application. I’m literally only stuck on the part where I need to be able to return a totally empty 200 OK page back to Slack to make it close a dialog window.
my slack integration is already successfully retrieving data from NetSuite, creating records, etc.
b
suitelets and restlets are inflexible in their inputs and outputs, the usual expectation should be the use of tools explicitly built for netsuite
j
I can’t believe I made it soooo close to what I needed and am stuck just on this one “ok” I have to send back
It’s just because NS for whatever reason forces a non-empty string for the
output
c
Have you tried other the content types availble from an SSP app? Maybe one of them will allow an empty response.
j
I’ll try but as I said at the start the documentation is kinda non-existant
I suspect no matter what, it will require something in the output
c
…/app/help/helpcenter.nl?fid=chapter_N3264137.html - a list of content types
j
oh.
my.
god.
I’m an eedjit.
I can just
return;
I don’t even have to
content.response.write();
anything
(from the SSP)
now to figure out how to do THAT in 3 seconds and still push the rest of the request on to do its thing
m
either trigger a background script to do the rest of the processing or create a queue custom record
💯 2
j
What would you suggest is the best way to trigger a background script?
m
Assuming you want it to be real time, you can create a scheduled script or map reduce with sufficient deployments for the number of concurrent background jobs. You then trigger using N/task without specifying a deployment and NetSuite will chose an available one. There are times this can still fail due to timing issues though
If within 15 minutes is ok, you can create a custom record to serve as a queue, and the suitelet would create a job in the custom record. A M/R every 15 minutes would then process any new custom records in the queue.
Another approach I've used before for asynchronous processing if you have a record the task is being performed on, is create a workflow with a single workflow action script with all the logic. Then you can trigger the workflow from your suitelet, and NetSuite will handle the queuing using the workflow queue.
j
urk. This is rather complex.
hm
the code won’t take long to run, might just be more that the 3 second limit within which I need to send back an ‘ok’