I am trying to get a custom field to update whenever the stock item attributes are updated, but I can’t find a way to make this work.
If base the row updated event on InventoryItem, it will update if other stock item fields are updated, but that doesn’t include the attributes.
If I base the row updated event on CSAnswers, then that does nothing.
Does anyone have any insight?
public class InventoryItemMaint_Extension : PXGraphExtension<PX.Objects.IN.InventoryItemMaint>
{
protected void _(Events.RowUpdated<InventoryItem> e)
{
var invRow = base.Base.Item.Current;
var invCache = base.Base.Item.Cache;
var extension = invCache.GetExtension<InventoryItemExt>(invRow);
if (invRow != null && invCache != null && extension != null)
{
var widthState = (PXStringState)invCache.GetValueExt(invRow, "WIDTH_Attributes");
var heightState = (PXStringState)invCache.GetValueExt(invRow, "HEIGHT_Attributes");
string width = PXStringState.GetStringValue(widthState, "D", "d");
string height = PXStringState.GetStringValue(heightState, "D", "d");
extension.UsrTestDimensions = $"Dimensions here: {width} x {height}";
invCache.Update(extension);
}
}
}