Hello,
I don’t know it is my code issues or system framework issue. Somehow, I encountered a case that the system can ignore the error on the screen and proceed to save and release document.
My environment is Build 21.208.0032. So I don’t know this issue still exists in current version.
My need is to forbid SO invoice being saved/released if any line contains 0 qty.
I am using the below code mainly
protected void ARTran_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
ARTran aRTran = (ARTran)e.Row;
if (aRTran != null)
{
using (new PXConnectionScope())
{
InventoryItem item = PXSelect<InventoryItem,
Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>
.Select(Base, aRTran.InventoryID);
if (item != null) {
if (aRTran.Qty == 0)
{
cache.RaiseExceptionHandling<ARTran.qty>(aRTran,
aRTran.Qty, new PXSetPropertyException("Qty Can NOT be 0", PXErrorLevel.Error));
}
else
{
cache.RaiseExceptionHandling<ARTran.qty>(aRTran, null, null);
}
}
}
}
}
Normally this code works OK. But if the user operates in the below steps, the system can bypass error and proceed.
1, Save an invoice normally with all lines not equal to 0 qty.
2, Purposely change a line qty to 0, like 3rd line, and then move the mouse focus to another line, let’s say the 2nd line.
And then, click save.
At that time, the system allows the 0 qty to be saved.
And then, click release. The invoice can be released with the red error alert on screen.
How can I enhance my code to fix the little hole? Please advise.