Solved

Stumped on setting a warning when LineTotal (CuryLineTotal) is less than 50

  • 16 January 2022
  • 4 replies
  • 233 views

Userlevel 5
Badge +1

I’m new to Acumatica and trying to get my head around adding what seems like a simple customisation.  I've been trying to get a warning to show when the line total is less than 50 on a Sales Order.  I have looked at other examples of how to raise a warning and tried various things but I’m not entirely sure what event handler it should go in as it’s not a user updatable field. I also think I should be using a different method to show the error but not sure what.

The following is what I have:

protected void SOOrder_CuryLineTotal_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e, PXFieldVerifying InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOOrder)e.Row;

if (row == null) return;

if (row.CuryLineTotal < 50)
{
throw new PXSetPropertyException("The order total is below the Wholesale minimum of $50.", PXErrorLevel.Warning);
}

}

The error gets thrown as a message box on the screen before I even get to open the order that has a lower value for the Line Total. I just want it to show a warning exclamation mark next to the Line Total if it’s less than 50 once the Sales Order is displayed.

 

Sorry if this is a noob question.

icon

Best answer by Naveen Boga 16 January 2022, 03:13

View original

4 replies

Userlevel 7
Badge +17

Most Welcome @ppowell 

Userlevel 5
Badge +1

@ppowell  The right place to write a code related to warning messages is RowEelected event, instead field selecting or field updated.

Thanks. Really appreciate the advice. I’ll change it to RowSelected then.

Userlevel 7
Badge +17

@ppowell  The right place to write a code related to warning messages is RowEelected event, instead field selecting or field updated.

Userlevel 5
Badge +1

After scouring the source code for PX.Objects.SO.SOOrderEntryExternalTax I found the right code now. 

For anyone else who runs into this:

PXUIFieldAttribute.SetWarning<SOOrder.curyLineTotal>(cache, e.Row, "The order total is below the Wholesale minimum of $50.");

I put it under FieldUpdated and FieldSelected event handlers.

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