In this NetSuite tutorial, I am going to demonstrate how we can programatically set multiple subsidiaries on a Vendor sublist when performing a data import. In our example, we are using the‘Vendor’ entity, which can have one or more subsidiaries associated with it – including a primary subsidiary, as shown in the below snapshot.
Now, everything would be fine if we were enter Vendors though the UI – but what if we have data from other systems that we need to import?
The CSV import tool does not allow you to map subsidiaries, as there is no provision for the Vendor Subsidiary relationship in the field mapping, as show in the below snapshot.
After doing some proof of concept work, we found that while we couldn’t map multiple subsidiaries to the out of the box “Subsidiary” field through the import tool, would could use it to accomplish the same task using code!
Since we wanted to import data using a CSV file – to accomplish this, we first needed to create a custom body field on the vendor record where we are going to store a string of all the subsidiaries that we’re looking to associate – in this example, I’ve named this field ‘vendor-subsidiaries.’ Our next step was to create a column in the CSV file to list all subsidiaries associated to the vendor.
Below is a small example of the CSV file, where you can see the Vendor, XYZPrint1, has 3 subsidiaries – Subsidiary 10, Subsidiary 20 and Subsidiary 30.
|Vendor – Subsidiaries
Note: The first value will always be handled as the primary subsidiary – and in this example it is 10. The value in the subsidiaries column represents the Internal Id of the subsidiary in NetSuite – and each subsidiary is separated by a delimiter character of ‘#’.
Finally, we wrote a user event script bound to the Vendor record as shown below – within the script, we used our custom string field of the delimited list of subsidiaries field from the vendor record to insert the actual subsidiaries.
As you can see in the above script, we read the values from ‘vendor-subsidiaries’ and then loop through the list and update the subsidiaries one by one. After each update, NetSuite adds the subsidiary to subsidiary sublist. Finally, line number 20 in our code sets the primary subsidiary.
With the simple code above, we were able to control the subsidiary sublist within the Vendor record, despite the fact that NetSuite does not expose this sublist in the record browser.
Get more from your NetSuite investment. Learn more about our NetSuite optimization services.
Thanks for reading this post on how to use a scripts to update hidden sublists in NetSuite. Please feel free to contact the MIBAR team if you’re looking for NetSuite support – we’re here to help you supercharge your NetSuite implementation!