Skip to main content

Is there a way to force a quantity more than 0 on a SO line?

This is more of a quality check for Customer Service during the order entry process.

Hi @jrichards ,


We can do below two options.

  1. Provide a validation, when Qty is Zero
  2. Provide default Qty is One

 

OPTION 1

It requires a small piece of customization. Please find the code for reference.

 public class SOOrderEntryEXT : PXGraphExtension<SOOrderEntry>
{
protected virtual void SOLine_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
SOLine row = (SOLine)e.Row;
if (row != null)
{
if (row.OrderQty == decimal.Zero)
{
sender.RaiseExceptionHandling<SOLine.orderQty>(row, row.OrderQty, new PXSetPropertyException("Quantity must be greater than 0", PXErrorLevel.Error));
}
}
}
}

 

OPTION 2

  • In OrderQty FieldDefaulting event, you can set the Default Qty as one. Please find the source code below.
    protected virtual void SOLine_OrderQty_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e, PXFieldDefaulting baseEvent)
{
baseEvent?.Invoke(sender, e);
SOLine row = e.Row as SOLine;
if (row == null) return;

if (row.OrderQty == decimal.Zero)
{
e.NewValue = row.OrderQty = 1;
}
}

 

Hope this helps!!


Reply