Skip to main content

PreSave Script for Sales Document Entry - Knowledgebase / SalesPad / Setup - Cavallo Technical Support

PreSave Script for Sales Document Entry

Authors list

To stop a user from processing an order with discontinued items, enter the following script in Security Editor > Sales Document Entry > Pre Save Script field:

// ================================
// begin DISCONTINUED items check
// ================================
string discontinuedMessage = "";

foreach(SalesPad.Bus.SalesLineItem sl in sd.LineItems)
{
if((sl.ItemMaster.val_Item_Type == "Discontinued" || sl.ItemMaster.val_USCATVLS_3 == "D") && !sl.IsMarkedToDelete)
{
e.Cancel = true;
if(discontinuedMessage == "")
{
discontinuedMessage = string.Format("The document contains the following discontinued items:{0}", sl.val_Item_Number);
}
else
{
discontinuedMessage += string.Format(", {0}",sl.val_Item_Number);
}
}

}
{ return discontinuedMessage; }

// ================================
// end DISCONTINUED items check
// ================================
return "";

Helpful Unhelpful