Solved

Proper Way to Access Cached Value of Custom Column in Sales Order Line Field Updated Event Handler


Userlevel 1


Hi Acumatica People,

I am working on a field updated event handler associated with the base order quantity associated with the sales orders lines.

I am a newbie to Acumatica development (took the t190 course) and I want to check the value of an extension column (for specific item classes we will utilize the value in a custom column). 

Here is a condensed version of my problem code: 
------------------------------
  public class SOOrderEntryExt : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{

      #region Event Handlers

      protected void _(Events.FieldUpdated<SOLine, SOLine.baseOrderQty> e)
      {
          if (e != null) 
          {

          SOLine row = (SOLine)e.Row;

          SOLineExt soLineExt = PXCache<SOLine>.GetExtension<SOLineExt>(row);

------------------------------
I want to view the value in the custom column and throw an exception on the base order quantity column under certain conditions.

I am using PXTrace.WriteInformation calls to check what is going on and it looks like soLineExt is always null (when I know it isn't). 

I don't think I'm properly getting the custom column's cache through this GetExtension invocation above.

How do I obtain the custom column's cache properly?

icon

Best answer by Leonardo Justiniano 3 April 2024, 01:55

View original

2 replies

Userlevel 6
Badge +4

Hi @PatrickBacon 

Try this way:

protected void _(Events.FieldUpdated<SOLine, SOLine.baseOrderQty> e)
{
if (e.Row != null)
{
SOLine row = (SOLine)e.Row;
SOLineExt soLineExt = e.Cache.GetExtension<SOLineExt>(e.Row);

// soLineExt.UsrField ...

...
}
}
  • Look for the cache used in the event (e.Cache)
  • Validate if the row is null (e.Row). The event variable always has a value but you can also validate for null if feel it necessary.

 

Userlevel 1

Leo, Thank you for the quick response. I made the modification and started testing and so far, so good.

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