Hello, all. I went through the T series courses and now I’m making my first modification to disable the InventoryCD field on the Stock Items form unless a specific Item Class (defined in Inventory Preferences extension) is selected.
I have it working, but when the field is enabled and you type in an InventoryCD, when you tab out, it states “Any unsaved changes will be discarded.” and sets the Item Class back to the default. All I want it to do is enable the field and allow manual entry.
I have separate code that is working to dynamically change the numbering sequence in the RowPersisting event.
Does anyone have any thoughts why the record is prompting “Any unsaved changes will be discarded?” It’s like it sees the record as “dirty.”
Here’s my code:
protected void InventoryItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
InventoryItem row = (InventoryItem)e.Row;
if (row == null)
{
return;
}
//lookup the autonumbering values on the Inventory Preferences screen
INSetup inSetup = Base.insetup.SelectSingle();
INSetupExt inSetupExt = inSetup.GetExtension<INSetupExt>();
if (row.ItemClassID != inSetupExt.UsrItemClassNotAutoNumberID)
{
//disable the field
PXUIFieldAttribute.SetEnabled<InventoryItem.inventoryCD>(cache, row, false);
}
else
{ //enable the field
PXUIFieldAttribute.SetEnabled<InventoryItem.inventoryCD>(cache, row, true);
}
}
Thanks,
Ryan