Skip to main content
Question

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

  • April 5, 2023
  • 4 replies
  • 237 views

param2022
Jr Varsity II
Forum|alt.badge.img

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

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • April 6, 2023

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");
}
}
}
}

 


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • April 6, 2023

@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. 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • April 6, 2023

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

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • May 17, 2023

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