I want to perform few validations on Sales order screen, I am comparing the Customer(customerID) field and the Customer Order(CustomerOrderNbr) field and try to give an error message if both the fields match.
I am not a programmer but I tried some code which is giving lot of errors and i'm not able to fix it...
namespace PX.Objects.SO
{
public class SOOrderEntry_Extension:PXGraphExtension<SOOrderEntry>
{
public const string ordernbrErrorMessage = "Customer name and customer number cannot be same.";
public void SOOrder_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
if (!ValidateCustomerID(sender, e.Row as SOOrder))
{
PXUIFieldAttribute.SetError<SOOrder.customerID>(sender, e.Row, ordernbrErrorMessage);
}
}
public bool ValidateCustomerID(PXCache sender, SOOrder soOrder)
{
if (soOrder != null)
{
string soCustomerID = PXSelectorAttribute.GetField(sender, soOrder, typeof(SOOrder.customerID).Name, soOrder.CustomerID, typeof(Customer.acctCD).Name) as string;
string soCustomerOrderNbr = soOrder.CustomerOrderNbr;
if (soCustomerID != null && soCustomerOrderNbr != null)
{
return !soCustomerID.Trim().Equals(soCustomerOrderNbr.Trim(), StringComparison.OrdinalIgnoreCase);
}
}
return true;
}
}
}
And this is my 1st entry with some customer name and order number
And this is my 2nd entry with same customer name and order number
After doing the changes in the code it isn't showing any error message...I restarted the website and checked but no results