Solved

Issue in the field verifying event

  • 20 March 2023
  • 4 replies
  • 175 views

Userlevel 1
Badge
throw new PXSetPropertyException(Messages.Test);

I have added the above code in FieldVerifying event of my custom field.
This does raise an error. But the new selected value is assigned to the field. 

Can anyone see what wrong I am doing here.

icon

Best answer by Naveen Boga 21 March 2023, 03:11

View original

4 replies

Userlevel 7
Badge +8

 

add 

e.Cancel = true;
return;

to your code.

Userlevel 1
Badge

Updated the code to this. But same issue still persist. 
I think when we throw the exception it is meant to cancel the assignment of the new value

@aaghaei

protected void INTran_UsrAccount_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e)
{
// logic for calculation
if (!isAccountInAccountGroup)
{
e.Cancel = true;
throw new PXSetPropertyException(Messages.Test);
}
}

 

Userlevel 4
Badge +2

Throwing the PXSetPropertyException does prevent assignment of the value into the Cache.  However, it is still shown in the UI to help illustrate the incorrect entry.  According to this  you are doing this correctly.

Userlevel 7
Badge +17

@tanuj81  It won’t assign the new value to the caches when you try to raise an exception.

I just checked with the code and it is working fine. Please find the code below and hope this helps!!

 

    public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
protected void SOLine_OrderQty_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e, PXFieldVerifying baseMethod)
{
baseMethod?.Invoke(cache, e);
SOLine row = e.Row as SOLine;
if (row != null)
{
if (row.OrderQty > 10)
{
throw new PXSetPropertyException("Qty should not be greater than 10");
}
}
}
}

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved