Netsuite | How to Use JSON.stringify(s) in server-side SuiteScript
JSON (JavaScript Object Notation) is available for client-side Suitescript, another popular usage JSON is the ‘stringify’ method it is primarily used in converting JavaScript data structures into JSON text.
In Netsuite suitescript JSON.stringify(s) is available in client-side script. However in server-side suitescript you will get an error when calling this method.
Stringify(s) is an open source code and it can be located at :
Copy the javascript source code and save it as a file and include it as a class library in your server-side script’s deployment.
Here is a sample usage in user event suitescript:
function onBeforeLoad(type, form, request)
{
if(type == "edit")
{
var transaction = new Object();
transaction.countryCode = "PH";
transaction.shipItem = "PS3";
var test = JSON.stringify(transaction);
nlapiLogExecution('DEBUG', 'json: ', test);
}
}
As a result, you would have a JSON format values in this format:
"{"countryCode":"PH","shipItem":"PS3"}"
Related posts:
Connect!
Enter your WordPress.com blog URL
http://.wordpress.com
Proceed