Skip to main content
Solved

Zero Quantity on Sales Order Line

  • March 25, 2022
  • 1 reply
  • 322 views

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.

Best answer by Naveen Boga

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!!

View original
Did this topic help you find an answer to your question?

1 reply

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • Answer
  • March 26, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings