Hi guys. I'm trying to get customers parent id. Le...
# suitescript
d
Hi guys. I'm trying to get customers parent id. Let say I have top level customer with id '1', then its child '2' and '3' which is a child of '2'. So when I call search.lookupFields({ type: search.Type.CUSTOMER, id: '3', columns: 'parent'}); I get '1' for some reason. But if I load the whole record '3' and just getValue({fieldId: 'parent'}) I get '2' as expected. Has anyone faced the same before?
c
The search column
parent
is specified to be the Top Level Parent according to the Records Browser: https://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2020_1/script/record/customer.html
d
Oh, I see. Thank you. So, no way to get closest parent?
c
If you don't want to load the record as in your example, you might be able to accomplish something with the Search Join
parentcustomer
You could also run the SuiteQL query
Copy code
SELECT parent FROM customer WHERE id = 3
which will give you the direct parent id.
d
Oh, yes, forgot about query module. Will try, thank you!
c
You're welcome! 🌞
d
Works like a charm! 🙂
🎉 1