Today I want to share with you the article "How to remove the validation of the Lot/Serial Class field on the Stock Items page".
Recently I had a case where I wanted to change Lot/Serial Class at any time regardless of its use, but out of the box, Acumatica doesn't give this possibility and show an error or warning "Lot/serial class cannot be changed when its tracking method as it is not compatible with the previous class and the item is in use" as it is demonstrated in the image below.
There is a possibility of this warning
The red error comes from validation on FieldVerifying, but the yellow comes from the rule in INItemPlan.inventoryID.InventoryLotSerClassIDRule. Although looks like a warning, it reverts your change so it doesn't let you to change it.
The solution of the Lot/serial class can be changed as it is not a complicated process but can be quite time-consuming.
First of all we need to create a GraphExtension where by overriding the Initialize we provide ability to change the Lot/Serial class.
And we also need to override the FieldVerifiyng event and not call the base method so that this field is not validated.
The full code is here:
public class InventoryItemMaintExt : PXGraphExtension<InventoryItemMaint>
private const string InventoryItemMaintExtCacheName = "InventoryItemMaintExt";
public static bool IsActive() => true;
public override void Initialize()
protected virtual void _(Events.FieldVerifying<InventoryItem,
InventoryItem.lotSerClassID> e, PXFieldVerifying baseMethod)
//skip the baseMethod so Messages.ItemLotSerClassVerifying is not thrown
And final word, use with caution. Because you may influence plenty of other pages in Acumatica.