Friday, January 4, 2019

Automatically inactivate out-of-stock Items via Workflow

There are cases where some items become out of stock and there are no estimate time on when those items will be available. Thus, to prevent placing orders against those items, vendors may opt to automatically inactivate them.

Out of stock items could automatically be set to inactive via Workflow through the steps below:

(1) Since the value of the available quantity, which is to be used as a condition of the set field value action, cannot be obtained directly from the Workflow, a Workflow Action Script is to created. Below is a sample code:

var itemID = nlapiGetRecordId();

// Define search filters
var filters = new Array();
filters[0] = new nlobjSearchFilter( 'internalid', null, 'anyof', itemID );

// Define return columns
var columns = new Array();
columns[0] = new nlobjSearchColumn( 'quantityavailable' );

// Create the saved search
var searchresults = nlapiSearchRecord( 'item',null, filters, columns );

for ( var i = 0; searchresults != null && i < searchresults.length; i++ )
var availQuantity = searchresults[ i ].getValue('quantityavailable');

return availQuantity;

(2) In the Workflow, a state field is to be created. It is on this field where the data coming from the script will be stored.

(3) Create a Workflow custom action, the custom action is to refer to workflow action script created in step 1.

To guide you in steps 1 to 3, you may refer in SuiteAnswers through the link below:


(4) Create a set field value action that is to set the 'Inactive' field to checked when <field in step 2> is empty.

No comments:

Post a Comment