how do i get a field value of a parent record and ...
# general
l
how do i get a field value of a parent record and store into a variable when the script is being applied to a child record? or vice versa - it does not really matter
r
Our standard routine is load record (the current). Then either getFieldValue of the parent internal id. We then either (load the parent, if there's ton's of variables needed) or (search, works nice for just finding a specific field or 2). I'd be glad to share code snippet if that would help. You in 2.0 or 1.0? @erictgrubaugh just posted you a response. He's head and shoulders above my head, and he's a 2.0 guru. I'm an old CPA (my excuse for having no confidence as a coder!)
j
@Robert Regnier Can you share an example with us?
r
Here's a real (today) example: Customer asks why international commerical invoice (part of our SuiteApp) is not showing the currency. I look at our shipment, and there's no currency. That shipment is created via a Suitescript from the item fulfillment record. So here's the 1.0 simple code to find the ifCurrency and then look at the parent sales order and see what the soCurrency value is. In your example, you're executing a script on a child. You need to lookup the parent, grab a field, and use it to nlapiSetFieldValue. So hopefully you can piece together something from my example. Snippet: var recType = nlapiGetRecordType(); var recType = nlapiGetRecordType(); var recId = nlapiGetRecordId(); var ifRec = nlapiLoadRecord(recType, recId); var soParentId = ifRec.getFieldValue('createdfrom'); var ifCurrency = ifRec.getFieldValue('currencycode'); var soCurrency = nlapiLookupField('salesorder', soParentId, 'currency'); Are you a Chrome browser user? I open the dev console when on any item fulfillment record, and past in those lines and you should get results.
Cheers!
l
Thank you so much for sharing this example