Question

Stop user from saving when there is an exception on Purchase request screen

  • 5 April 2023
  • 4 replies
  • 179 views

Userlevel 2
Badge

I don’t want user to save the record if there is any error, I wrote a custom fieldverifying event for the RQRequestLine and it works fine when the values is selected however, it allows user to save the record event if there is rowpersisting event written that calls fieldVerifying event.

 

protected void RQRequestLine_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{
var row = (RQRequestLine)e.Row;
if (row != null)
{
object newValue = row.ExpenseAcctID;
this.Base.Lines.Cache.RaiseFieldVerifying<RQRequestLine.expenseAcctID>(row, ref newValue);
}
}


protected void RQRequestLine_ExpenseAcctID_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e)
{
// logic
cache.RaiseExceptionHandling<RQRequestLine.expenseAcctID>(row, Act?.AccountCD,
new PXSetPropertyException(Messages.Test, PXErrorLevel.Error, row.ExpenseAcctID));

}

 


4 replies

Userlevel 7
Badge +17

HI @param2022  Here is the sample code 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 (CONDITION)
{
throw new PXSetPropertyException("ERROR MESSAGE");
}
}
}
}

 

Userlevel 2
Badge

@Naveen Boga I also tried this particular code. But issue I am facing with this one is that I have written the code for ExpenseAcctID a Account selector, when i throw exception it displays the AccountID instead of the AccountCD which is why I was using the above approach so in RaiseExceptionHandling I can provide the newValue parameter and show AccountCD inssted of AccountID. 

Userlevel 7
Badge +17

@param2022 Yes, I don’t see any issues with the code provided by you and should work.

 

Userlevel 7
Badge

Hi @param2022 were you able to find a solution? Thank you!

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