New Customer – Pre Save Example

New Customer – Pre Save Example

This Pre-Save will not allow a new customer to be created without the Address Code

string message = "";	
if(SalesPad.Bus.CustomerAddr._Address_Code == "BILL")	
{	
	e.Cancel = true;
	message += "Enter a Customer Name\n";
}	
return message;

Cheers!
Sanjay

 

Customer Address Card Pre Save Script

Customer Address Card Pre Save Script

This Pre-Save will not allow not allow a   customer address to be saved unless a Zip Code is entered.
string message = "";
if (addr.val_Zip == "")
{
e.Cancel = true;
message += "Enter a Zipcode\n";
}
return message;

Source : Salespad.net

Cheers!
Sanjay

 

Sales Document Entry – Pre Save Example:

Sales Document Entry – Pre Save Example:

This pre save will stop the user from saving the document if a PO Number is not entering  a duplicate on a sales document.

	if(sd.val_Sales_Doc_Num == "")	
	{	
		if (sd.val_Customer_PO_Num == "")
	            {	
	                e.Cancel = true;	
	                return "Please enter a customer po number.";	
	            }	
	            else	
	            {	
	                SalesPad.Bus.SalesDocuments sds = new SalesPad.Bus.SalesDocuments();	
	                System.SearchClause sc = new System.SearchClause(Bus.SalesDocument._Customer_PO_Num, "=", sd.val_Customer_PO_Num);	
	                sc.And(Bus.SalesDocument._Customer_Num, "=", sd.val_Customer_Num);	
	                sc.And(Bus.SalesDocument._Sales_Doc_Num, "<>", sd.val_Sales_Doc_Num);	
	                sds.Load(sc);	

	                SalesPad.Bus.SalesDocumentHistorys sdh = new SalesPad.Bus.SalesDocumentHistorys();	
	                System.SearchClause sc2 = new System.SearchClause(Bus.SalesDocument._Customer_PO_Num, "=", sd.val_Customer_PO_Num);	
	                sc2.And(Bus.SalesDocument._Customer_Num, "=", sd.val_Customer_Num);	
	                sc2.And(Bus.SalesDocument._Sales_Doc_Num, "<>", sd.val_Sales_Doc_Num);	
	                sdh.Load(sc);	

	                if (sds.Count > 0)	
	                {	
	                    //e.Cancel = true;	
	                    return string.Format("Customer PO number was user on order: {0}", ((Bus.SalesDocument)sds[0]).val_Sales_Doc_Num);	
	                }	
	                else if (sdh.Count > 0)	
	                {	
	                    //e.Cancel = true;	
	                    return string.Format("Customer PO number was user on order: {0}", ((Bus.SalesDocument)sdh[0]).val_Sales_Doc_Num);	
	                }	
	                else	
	                {	
	                    return "";	
	                }	
	            }	
	}	
	else	
	{	
		return "";
	}

Cheers!
Sanjay