Jul 27 2017
Posted By : aecc
In NetSuite, there is a kind of record called subrecord, it is similar to the record and most of the record APIs can be used on the subrecord. The most significant different between the record and a subrecord is that the subrecord must have a parent record, the subrecord cannot exist in the system without attach to a record. So if you want to update the subrecord, you need to access the parent record.
The most common subrecord is the inventory detail subrecord.
We can access a subrecord in the sublist by using the sublist API:
This API will return the subrecord object called nlobjsubrecord.
The following script shows how to create an inventory subrecord, in this script, we’re trying to create a new subrecord for the inventory filed on the item sublist.
var subrecord = record.createCurrentLineItemSubrecord('item', 'inventorydetail'); subrecord.selectNewLineItem('inventoryassignment'); subrecord.setCurrentLineItemValue('inventoryassignment', 'issueinventorynumber', '10010'); subrecord.setCurrentLineItemValue('inventoryassignment', 'quantity', 1); subrecord.commitLineItem('inventoryassignment'); subrecord.commit();
We set the inventory number (Serial/Lot Number) to “10010” and put a quantity of 1 onto this line.
Don’t forget to commit() the changes at the last step, otherwise the changes will not be saved.
After running the above script, the subrecord are populated.
How to create a button in NetSuite to open a saved search result
How to Prevent User from Editing the Record — Using Client Side Script.
Include Custom Module in NetSuite 2.0 Script.
Overcome saved search each() function limitation
Working with Subrecord on SuiteScript