I'm trying to create a record reference for the su...
# suitescript
s
I'm trying to create a record reference for the subsidiary. Can somebody tell me why result[0].values is undefined? I'm seeing the following JSON for result[0],
{"recordType":"subsidiary","id":"3","values":{"internalId":[{"value":"3","text":"3"}],"externalId":[]}}
I'm getting the following error from the function; TypeError Cannot read property 'internalId' of undefined If I take the JSON outside of NetSuite, I'm able to access the internalId without a problem.
b
on a technical level, the object you are logging is not the same object you are using
suitescript 2.0 makes extensive use of toJSON, since all the logging methods stringify objects, the object logged is different than the object you are working with
you are supposed to use Result.getValue to get values out of search results
s
Ahh, ok. Thank you for the feedback. So you are saying for logging, just log result[0] and don't perform the stringify?
b
if for some reason you want to rely on the undocumented json form, you can directly use .toJSON on your search results
s
👍
b
logging result[0] is equivalent to logging JSON.stringify(result[0)