Sunday, December 23, 2018

Remove an Item from the Web Store when the Available Quantity is Zero

This document is to guide the users on how they to disable the  "Display in Web Store" field on Inventory Part Items via Workflow when Available Qty is 0.

(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 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 users in steps 1 to 3, please refer in SuiteAnswers through the link below:

Return a Value from a Workflow Action Script

(4) Create a set field value that is to set the field 'Available Online' to checked where the condition is <field in step 2> is greater than 0.

Note: 'Available Online' field corresponds to the 'Display in Web Store' field on the Item record. Also, it is by design that when the 'Display in Web Store' is enabled, the 'Allow Google Checkout Purchase' also gets enabled

No comments:

Post a Comment