SuiteScript Example – Multi-location Reorder Point

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.

multlocation preferred stock levels

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);
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s