ClientScript Question, On an Invoice, what is the ...
# suitescript
n
ClientScript Question, On an Invoice, what is the most efficient way to get the Document Number of the Created From Sales Order. 1. Get the Sales Order Id from the Created From Field and Load the record then call
getValue
on the Sales Order Record 2. Call
getText
on Created From Field and parse out the Document Id Option 2 seems a lot more efficient but potential for mistakes, Option 1 seems terrible inefficient but a sure value.
s
I use
search.lookupFields()
to get the tranId and type, to ensure the 'createdfrom' is actually a sales order -- unless you always know it's a sales order.
n
Good call, need to consider an Invoice created from something other than Sales Order
s
Or if the Invoice was created as stand-alone, and it doesn't have a createdfrom.
you can use the
getText
on the field, but if they ever change the name of 'Sales Order' to something else, you would have to update the script.
a
@nathanw As @suitedev mentioned you can use
search.lookupFields()
, if you are worry about the Type you can use
record.Type.TRANSACTION
and then get the
tranid
.
e
Technically, you should probably use
search.Type.TRANSACTION
, but I agree otherwise!
💯 1
s
I don't think there's an ENUM for 'TRANSACTION'
I usually have to type in
'transaction'