Hello, i want to send json format data from a save...
# suitescript
h
Hello, i want to send json format data from a saved search results to an external application. What's the best way to do it? Thanks
c
If the external application has an API to talk to it, you can send the results that way. Or alternatively, have the external app poll netsuite for changes and you write your own restlet.
or you can export the results and do what you want with them...really depends honestly. Would need more info about the "external app"
e
Copy code
var data = search.create(...)
  .run()
  .getRange(...)
  .map(result => {
    return {
      name: result.getValue({name: "entityid"}),
      email: result.getValue({name: "email"})
    };
  });

var jsonString = JSON.stringify(data);
or
Result
instances have their own
toJSON()
method if you just want NetSuite's default object format for a search result
h
@creece I was asked to send it as a "queue" to aws (not super familiar with this).
Thanks @erictgrubaugh
m
@erictgrubaugh I've used result.toJSON() before but always been a little scared that it's not officially documented. Do you think it's considered safe? Especially considering that the format is the same as what's passed to map/reduce steps so if NetSuite would change it that would break a lot of M/R scripts.
e
I don't use it myself; I'm typically very explicit about the data structures I use/create
plus, i just don't like the result of
toJSON
🙂