Is it possible to output JSON as a response from a...
# suitescript
m
Is it possible to output JSON as a response from a suitelet?
e
Yes- here's an example, at the end of the function, instead of context.response.writePage(), you can use context.response.write() like so
Copy code
return context.response.write(
    JSON.stringify({
        status: 'SUCCESS',
        details: `Record Transformed Successfully! Record Id: ${savedRecordId}`
    })
)
m
oh okay I had it working like that for a bit but I was worried that it would return in string format and not in JSON format
e
It will. But you could add a client script to your suitelet that could read the string format and parse it back to a JSON object
m
👀 seriosly?
that's really cool, I'll have to figure that one out
e
https://ceanatech.com/2019/11/06/suitescript-2-0-sample-code-for-filtering-a-dropdown-field/ This article will show how to attach a client script to a suitelet. Written by @Lea CC
m
awesome