// preventCreatePOorWO is used to stop NS from automatically creating a PO or WO // when an item has a quantity available >= the quantity on the order. This only // occurs as the Order Confirmation is being approved. preventCreatePOorWO: function(type) { var lineCount = nlapiGetLineItemCount('item'); for (var i = 1; i <= lineCount; i++) { var createPO = nlapiGetLineItemValue('item', 'createpo', i); var createWO = nlapiGetLineItemValue('item', 'createwo', i); if (createPO == 'SpecOrd' || createWO == 'T') { var avail = nlapiGetLineItemValue('item', 'quantityavailable', i); var needed = nlapiGetLineItemValue('item', 'quantity', i); nlapiLogExecution('debug', 'Record:' + nlapiGetRecordId(), 'Line ' + i + ' has ' + avail + ' available and ' + needed + ' are needed.'); // Uncheck the Create PO or Create WO checkbox if (avail >= needed) { nlapiLogExecution('debug', 'Record:' + nlapiGetRecordId(), 'Line ' + i + ' will be unchecked.'); nlapiSetLineItemValue('item', 'createpo', i, ''); nlapiSetLineItemValue('item', 'createwo', i, 'F'); } } } return true; } // End preventCreatePOorWO function