0

What is the internal field ID of the subcustomers list? I can't seem to locate the internal field ID of the subcustomers list on parent customer records. It's not on the customer record page on the Record Browser, and it's definitely not a custom record or list, so I'm kinda lost. Any help?

For context: I'm writing a script to update the billing address of all child records when the billing address of the parent record has been changed. So I need the field ID of the subcustomers list so I can loop through each record.

John
  • 302
  • 2
  • 23

1 Answers1

3

You can search the customers where parent is current customer and get the ids of the children customers.

nlapiSearchRecord('customer', null, ['parent', 'anyof', PARENT_CUSTOMER_ID]);

For scripting you can write a user event and in case of user event your PARENT_CUSTOMER_ID would be the current record Id itself which you can get using nlapiGetRecordId() in your user event script on parent customer.

For God known reasons, NetSuite is pulling up the PARENT_CUSTOMER_ID record also in the search result, so, better to filter it off with an additional criteria

nlapiSearchRecord('customer', null, [['parent', 'anyof', PARENT_CUSTOMER_ID], 'and', ['internalid', 'noneof', PARENT_CUSTOMER_ID]])
prasun
  • 7,073
  • 9
  • 41
  • 59
  • 1
    Perfect! Thank you once again for helping me out! I knew there was a better way to do this :) – John Oct 26 '15 at 16:58
  • 1
    nlapiSearchRecord('customer', null,[ ['parent', 'anyof', PARENT_CUSTOMER_ID], 'and', ['internalid', 'noneof', PARENT_CUSTOMER_ID]]); – prasun Oct 27 '15 at 17:45
  • You were fast! I removed my comment because I thought I had figured it out. Like the Help Center details, I tried making a filters array like this: var filters = []; filters[0] = new nlobjSearchFilter('parent', null, 'anyof', parentId); filters[1] = new nlobjSearchFilter('parent', null, 'noneof', '@NONE@'); I feel like this worked, what do you think? – John Oct 27 '15 at 17:48
  • 1
    your filter might fail, if the PARENT record itself is child of one, thoughts? – prasun Oct 27 '15 at 17:51
  • good point, though I think we might be okay. To play it safe, I think I will use what you've provided. Thanks again! – John Oct 27 '15 at 17:52