Question

Disable InventoryItem.InventoryCD Based on Item Class from Inventory Preferences

  • 19 November 2022
  • 1 reply
  • 86 views

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


1 reply

I believe the issue is that on a new record, the user must select a specific Item Class in order for the InventoryCD field to be enabled.  The issue is by picking an item class, the record is now “dirty.”  When they go to enter a value into the InventoryCD, some logic is causing the record to refresh, which resets the item class.  I have chosen to solve this issue in a different way, but I’d still love to hear if anyone has had a similar experience and overcome it.

Thanks again,

Ryan

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved