Sales pad pre save script – at least one field of line items should be filled.

Sales pad pre save script – at least one field of line items should be filled.

Sales pad allows to add unlimited user defined fields to  supplement Microsoft Dynamics GP.  Apart from adding user defined fields, sales pad allow limited validated of these field while data entry through pre save scripts.  The pre save scripts are c# scripts and the data base object are provided by sales pad SDK.

Below is the sample script to validate at least one of the line item is updates.

if (sd.val_Sales_Doc_Type.Equals(“SD”, StringComparison.CurrentCultureIgnoreCase))
{
string y;
y = “”;
foreach (SalesPad.Bus.SalesLineItem sli in sd.LineItems)
{
if (String.IsNullOrEmpty( sli[“xUDF”].ToString()       ))
{
}
else
{
y =  sli[“xUDF”].ToString();
}
}
if (String.IsNullOrEmpty(y.ToString() ))
{
e.Cancel = true;
Messenger.Show(“The xUDF field needs to be filled in.”);
}
else
{
Messenger.Show(“UDF test passed.”);
}
}

Where   SD would be Microsoft Dynamics GP Sales Document Type and xUDF would be the Sales pad user defined field.

Cheer!