Hey all - I'm trying to get the tranid of a Sales ...
# suitescript
t
Hey all - I'm trying to get the tranid of a Sales Order: I create the SO, set the fields, then call .save() on the Sales Order record. Then, I try to getValue of tranid but it comes back as To Be Generated. Any idea why it doesn't get generated after calling save?
b
you will have to lookup the tranid or load the sales order
r
record.lookupFields() once you have the internal id of the sales order
b
the tranid is set after beforeSubmit so it won't be reflected on the record in the context
💯 2
t
Ahhh good to know! Thanks!
s
this is correct. basically, do the following:
var id = so.save(); var soValues = search.lookupFields({ type: search.Type.SALES_ORDER, id: id, columns: ['tranid'] }); var tranId = soValues.tranid;
💯 1
t
My heros! Thanks all, it's working perfectly now
👍 1
s
I generally load the record rather than run a search