Skip to main content
Answer

Why does my custom field no longer update after upgrade from 2022R2 to 2023R2?

  • March 11, 2024
  • 6 replies
  • 103 views

Forum|alt.badge.img+1

I have a customization which updates a custom date field when another custom field (called UsrAIWHLPrice) is updated.  This has been working fine since 2022.  Since upgrading to 2023R2 the field doesn’t update any longer. 

 

The code is below:

 

protected void InventoryItem_UsrAIWHLPrice_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (InventoryItem)e.Row;

if (row == null) return;

try{

InventoryItemExt invItemExt = PXCache<InventoryItem>.GetExtension<InventoryItemExt>(row);
if (invItemExt.UsrAIWHLPriceChangeDate != null) {
invItemExt.UsrAIWHLPrevPriceChangeDate = invItemExt.UsrAIWHLPriceChangeDate;
}

invItemExt.UsrAIWHLPriceChangeDate = PX.Common.PXTimeZoneInfo.Now;

}
catch (Exception error) {
PXTrace.WriteInformation("error: " + error);
}
}

There is no error in trace so I suspect it is because I haven’t used the correct method to update the field in the extension. I think I should be updating the cache instead but I’m not sure how to do that.

 

Can anyone advise where I’m going wrong?

 

Thanks,

 

Phil

Best answer by darylbowman

@jinin - I think you meant

cache.SetValueExt<InventoryItemExt.usrAIWHLPrevPriceChangeDate>(Base.Item.Current, invItemExt.UsrAIWHLPriceChangeDate);

and 

cache.SetValueExt<InventoryItemExt.usrAIWHLPriceChangeDate>(Base.Item.Current, PX.Common.PXTimeZoneInfo.Now);

 

6 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • March 11, 2024

Hi @ppowell ,

Could you please try the below code?

protected void InventoryItem_UsrAIWHLPrice_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            var row = (InventoryItem)e.Row;
            if (row == null) return;

            try
            {
                InventoryItemExt invItemExt = PXCache<InventoryItem>.GetExtension<InventoryItemExt>(row);

                if (invItemExt.UsrAIWHLPriceChangeDate != null)
                {
                    invItemExt.Item.SetValueExt<InventoryItemExt.usrAIWHLPrevPriceChangeDate>(Base.Item.Current, invItemExt.UsrAIWHLPriceChangeDate);
                   // invItemExt.UsrAIWHLPrevPriceChangeDate = invItemExt.UsrAIWHLPriceChangeDate;
                }
                invItemExt.Item.SetValueExt<InventoryItemExt.usrAIWHLPriceChangeDate>(Base.Item.Current, PX.Common.PXTimeZoneInfo.Now);
               // invItemExt.UsrAIWHLPriceChangeDate = PX.Common.PXTimeZoneInfo.Now;
            }
            catch (Exception error)
            {
                PXTrace.WriteInformation("error: " + error);
            }
        }


darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • March 11, 2024

@jinin - I think you meant

cache.SetValueExt<InventoryItemExt.usrAIWHLPrevPriceChangeDate>(Base.Item.Current, invItemExt.UsrAIWHLPriceChangeDate);

and 

cache.SetValueExt<InventoryItemExt.usrAIWHLPriceChangeDate>(Base.Item.Current, PX.Common.PXTimeZoneInfo.Now);

 


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • March 11, 2024

Yes @darylbowman .

Given the alternative approach to determine if it will work or not.


Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • March 11, 2024

@jinin Unfortunately I get the following error with that method when verifying:

[2024-03-11 15:55:01.974] \App_RuntimeCode\InventoryItemMaint.cs(380): error CS1061: 'InventoryItemExt' does not contain a definition for 'Item'

@darylbowman Thanks.  Changing to cache.SetValueExt works.

 

One question:

After posting I had tried a few things myself and come up with:

cache.SetValueExt<InventoryItemExt.usrAIWHLPrevPriceChangeDate>(row, invItemExt.UsrAIWHLPriceChangeDate);

and

cache.SetValueExt<InventoryItemExt.usrAIWHLPriceChangeDate>(row, PX.Common.PXTimeZoneInfo.Now);

which also seem to work OK.

Is using Base.Item.Current preferable to using row?

 

Thanks for all your help,

Phil


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • March 11, 2024

Hi @ppowell ,


Oh, sorry typo mistake 🙂

You can use the row as well. 


darylbowman
Captain II
Forum|alt.badge.img+15

Is using Base.Item.Current preferable to using row?

I personally use row