I have had set my custom field 'UsrPrintQty' to be enabled on POReceiptLine_RowSelected event as below:
protected void POReceiptLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (POReceiptLine)e.Row;
PXUIFieldAttribute.SetEnabled<POReceiptLineExt.usrPrintQty>(cache, row, true);
//PXUIFieldAttribute.SetEnabled(cache, row, "UsrPrintQty", true);
}
And it is working perfectly on my development server with the Acumatica version 18.200.0075. But when I published the customization to the another instance with the version 18.112.0019, it just doesn't work.
I debug the code and the line is being hit too. I set the highest customization level guessing there might be chance that other code is overriding this one. I restart the application via Apply Updates. I even changed the event from RowSelected to RowSelecting. I tried the different overloaded method of SetEnabled (which is commented in the above code).
But nothing works.
If I put these two lines:
cache.AllowUpdate = true;
Base.transactions.Cache.AllowUpdate = true;
then it allows me to update but then I can update the whole row which I don't want to.
I also set the field property AllowUpdate to true.
But still no luck.
Thank you.
The cache AllowUpdate method takes precedence on SetEnabled method. Calling the cache AllowUpdate with false parameter is commonly used on closed document to prevent any modification.
If you require the user to be able to modify one field of a closed document you'll have to jump through some hoops. Setting AllowUpdate to true after the base graph has set it to false is necessary.
Try this pattern:
// Required to enable any field
Base.transactions.Cache.AllowUpdate = true;
// Set all fields to false
PXUIFieldAttribute.SetEnabled(Base.transactions.Cache, null, false);
// Set the only field we want to enable to true
PXUIFieldAttribute.SetEnabled<POReceiptLineExt.usrPrintQty>(Base.transactions.Cache, null, true);