hello team, I am trying to pass a NS record (a Jou...
# suitescript
a
hello team, I am trying to pass a NS record (a Jounal Entry) from one script to another, via a parameter. I am using for this JSON.stringify() to convert the jeRecordObj into a string, then passing that string as a parameter to the scheduled script. On the scheduled script, I get the string parameter passed in, and do JSON.parse() to build back the jeRecordObj. This is not working fine, as I cannot manipulate the built object with normal methods, like jeRecordObj.getValue(), etc. I think the issue is related to the “data loss” when using stringify/parse. Any experience with this? Suggestions? Any other method without data loss to serialized/deserialize a JSON object?
c
just pass the ID and have the other script get the info
a
well, the issue is that the JE is an incomplete journal that cannot be saved. So, I need to pass the object as it is from one script to the other
I have done this successfully with a simpler object, like an array. This works great, but not with a NetSuite record, it seems
j
Yeah, the JSON.stringify() and JSON.parse() breaks it. You will have to pass the data for the JE only and then have the scheduled script create and save the JE.
a
the issue is that I need to build half of the JE in one script, half in the other
the issue is that script is reaching the limit governance, the JE is too big
j
I don't believe this is possible. Which methods are you using that are eating up your governance? If I'm not mistaken only record.create() and record.save() use governance, but not field and sublist field value setting. Are you doing a lot of searches and lookups perhaps?
w
You might want to just create a hand-rolled JSON: ie: { type: “journalentry” line: [ { account: 123, debit: 100, }, { account: 456, credit: 100 }, . . . } JSON.stringify it, pass to script parameter and JSON.parse it to convert back to JSON, this way you have more control.
a
thanks, I will check the logic to see what consumes governance, but probably lookups and SuiteQL
I will try to build a simpler objet from lookups and pass that on to the script that finally creates the JE out of the temp/simple object
k
I would not go there but maybe Hydrate.js might help you
The string though might be huge