Hi everyone,
Does anyone know how to make the "Salesperson" field in customer mandatory?
I’ve already set the field as required, but unfortunately, it has no effect — I can still save the record without entering a value.


Thanks in advance!
Hi everyone,
Does anyone know how to make the "Salesperson" field in customer mandatory?
I’ve already set the field as required, but unfortunately, it has no effect — I can still save the record without entering a value.


Thanks in advance!
Best answer by DipakNilkanth
Hi
If none of the above solutions work, you can create a small code customization:
protected void Customer_RowPersisting(PXCache cache, PXRowPersistingEventArgs e, PXRowPersisting InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (Customer)e.Row;
if (row == null) return;
// Check if any CustSalesPeople is linked
var salesPeople = PXSelect<CustSalesPeople,
Where<CustSalesPeople.bAccountID, Equal<Required<Customer.bAccountID>>>>
.Select(Base, row.BAccountID);
bool hasSalesPerson = salesPeople.RowCast<CustSalesPeople>().Any(sp => sp.SalesPersonID != null);
if (!hasSalesPerson)
{
throw new PXRowPersistingException(typeof(CustSalesPeople.salesPersonID).Name, null, "At least one Salesperson is required.");
}
} Hope, it helps!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.