Prevent Entry of Duplicate Items in a Sales Order

To restrict users from entering duplicate items in a Sales Order, or any transaction with an item sublist, a simple Client script with a validateLine function can be deployed with the sample code below:

 function validateLineSO(){ 
  var lineCount = nlapiGetLineItemCount('item'); 
  for(var i = lineCount; i>0 ; i--)
  {  
   if(nlapiGetCurrentLineItemValue('item', 'item')==nlapiGetLineItemValue('item', 'item',i)&&i!=nlapiGetCurrentLineItemIndex('item'))
   {   
    alert('Duplicate Item');   
    return false;  
   } 
  }
  return true;
 }

Leave a comment

Your email address will not be published. Required fields are marked *