I needed to default the reorder point and preferred stock level on new inventory items. My problem: We use multi-location inventory. That meant I needed to set these fields in a sublist, not in the main record’s body fields. I already had an event script written in SuiteScript 1.0, so I wanted to add code to set those 2 fields for the Kansas City location.
Here’s some sample code that locates those 2 fields in SuiteScript 1.0.
var record = nlapiLoadRecord(‘inventoryitem’, ‘[itemid here]’);
var count = record.getLineItemCount(‘locations’);
for (var i = 1; i <= count; i++) {
var locationid = record.getLineItemValue(‘locations’, ‘locationid’, i);
var location_name = record.getLineItemValue(‘locations’, ‘location_display’, i);
var reorderpoint = record.getLineItemValue(‘locations’, ‘reorderpoint’, i);
var preferredstocklevel = record.getLineItemValue(‘locations’, ‘preferredstocklevel’, i);
nlapiLogExecution(‘DEBUG’, ‘location: ‘ + locationid + ‘ – ‘ +
location_name + ‘ – ‘ + reorderpoint + ‘ – ‘ + preferredstocklevel);
}