Skip to main content
Solved

Getting a red X not a yellow exclamation for a warning


Joe Schmucker
Captain II
Forum|alt.badge.img+3

I am not a good programmer so please feel free to tell me all the things I could do better…  :-)

I am working in 2021R1.

I have a field that I am validating to make sure that it does not exceed a total amount on the header record.  

My screen is functioning properly, but I should be getting a warning indicator, not an error.

My RaiseExceptionHandling is set at the Warning level BUT, I get a red X on the screen.  What am I doing wrong here?

 

        protected virtual void _(Events.FieldVerifying<GRGrantsCustomers, GRGrantsCustomers.allocatedAmount> e)
        {
            GRGrantsCustomers row = e.Row;
            GRGrants grant = Grant.Current;
            decimal? newValue = (decimal)e.Args.NewValue;
            decimal? total = 0;

            foreach (GRGrantsCustomers item in Customers.Select())
            {
                total += item.AllocatedAmount;
            }

            if (total - row.AllocatedAmount + newValue > grant.GrantAmount)
            {
                decimal balanceBeforeThisLine = grant.GrantAmount - total + row.AllocatedAmount ?? 0;
                string balanceAvailable = balanceBeforeThisLine.ToString("0.##");

                e.Cache.RaiseExceptionHandling<GRGrantsCustomers.allocatedAmount>(row,
                    balanceBeforeThisLine,
                    new PXSetPropertyException(Messages.AllocatedTooMuch, balanceAvailable, PXErrorLevel.Warning));

                e.NewValue = balanceBeforeThisLine;
            }
        }
This is what the screen looks like when I enter 600 in the second line.  It correctly sets it to 500, but it I want a yellow warning! 

 

 

Best answer by Hughes Beausejour

Try moving the warning to RowSelected event and replace PXSetPropertyException with SetWarning method:
protected virtual void _(Events.RowSelected<GRGrantsCustomers> e)
{
    PXUIFieldAttribute.SetWarning<GRGrantsCustomers.allocatedAmount>(e.Cache, e.Row, Messages.AllocatedTooMuch);
}

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

2 replies

Hughes Beausejour
Acumatica Employee
Forum|alt.badge.img+2
  • Acumatica Developer Support Team
  • 91 replies
  • Answer
  • April 26, 2021

Try moving the warning to RowSelected event and replace PXSetPropertyException with SetWarning method:
protected virtual void _(Events.RowSelected<GRGrantsCustomers> e)
{
    PXUIFieldAttribute.SetWarning<GRGrantsCustomers.allocatedAmount>(e.Cache, e.Row, Messages.AllocatedTooMuch);
}


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • 443 replies
  • April 26, 2021

Hughes Beausejour, AWESOME!  Thank you for the quick assistance!

That worked perfectly.  I left this in the FieldVerifying event handler so I could change the amount of the field before the row was updated, but your code did the trick in my event.  I was trying to use the same methodology as in the T190 course but this is a much simpler statement too.  

I’m a lone ranger (just me here) and I wouldn’t know what to do if it wasn’t for people like you and Naveen in this forum.  You guys are life savers.


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