Skip to main content
Solved

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


Forum|alt.badge.img


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?

Best answer by Leonardo Justiniano

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.

 

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

2 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+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.

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 16 replies
  • April 3, 2024

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


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