Errors out while saving custom field data into InItemLotSerial table

I have a requirement to add custom fields to the InItemLotSerial table. I have added an extension table to InItemLotSerial to accept custom values through the custom page.

I am accepting custom data for each serial number in InventoryItem enter image description here

I have added the following event in POReceiptEntry extension to fill the value of custom fields from Inventory Item.

Base.RowInserted.AddHandler<ItemLotSerial>((sender, e) =>
            {
                var serialrow = (ItemLotSerial)e.Row;
                if (serialrow != null)
                {
                    InfoINItemLotSerialExtNV serextrow = PXCache<INItemLotSerial>.GetExtension<InfoINItemLotSerialExtNV>(serialrow);
                    InventoryItem itm = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, serialrow.InventoryID);
                    if (itm != null)
                    {
                        InfoInventoryItemAttributeExtNV extrow = PXCache<InventoryItem>.GetExtension<InfoInventoryItemAttributeExtNV>(itm);
                        if (extrow != null)
                        {
                            serextrow.SearchType = extrow.SearchType;
                            serextrow.DiamondColor = extrow.DiamondColor;
                        }
                    }
                }
            });

While debugging the event is triggered and the values are assigned to custom fields, but it throws error while saving the purchase receipt.

enter image description here

`

`

Upvotes: 0

Views: 150

Answers (1)

RuslanDev
RuslanDev

Reputation: 6778

ItemLotSerial is decorated with the ItemLotSerialAccumulator attribute and totally relies on it in terms of persisting changes to the database:

[ItemLotSerialAccumulator]
[Serializable]
public partial class ItemLotSerial : INItemLotSerial, IQtyAllocatedBase
{
    ...
}

Currently, accumulators do not support extension tables, so your best option might be to use a regular extension for the INItemLotSerial DAC over an extension table. This approach should also resolve the issue mentioned in your other post Getting Error : Invalid Column NoteId

Upvotes: 1

Related Questions