Skip to main content
Answer

Read only field in grid by Field update event

  • October 17, 2023
  • 2 replies
  • 266 views

Forum|alt.badge.img

Hi Team,

Need to know how to enable or disable specific field based on the another field value. Can someone help me? Here is my code

protected void _(Events.FieldUpdated<HMRCVendorRegisterDetail, HMRCVendorRegisterDetail.verifiedTypeID> e)
        {
            HMRCVendorRegisterDetail row = e.Row;

            if (row == null) return;

            if (e.OldValue != e.NewValue)
            {
                if (row.VerifiedTypeID.Equals("M"))
                {
                    row.VerificationNote = "Manual Verified By " + PXAccess.GetUserName() + " On :" + DateTime.Now.ToString();
                     //row.VerifiedDate  Need to Enable/Disable this field
                }
                              
            }
        }

Best answer by Yuriy Zaletskyy

You need to use SetEnabled method of PXUIFieldAttribute. Also make sure, that you use RowSelected event of main DAC class, otherwise, may be ommited from execution ( I don’t know why ). Below goes fragment of Acumatica source code:

 

		protected virtual void Vendor_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
Vendor vendor = (Vendor) e.Row;
T5018VendorExt extension = PXCache<BAccount>.GetExtension<T5018VendorExt>(vendor);
if (vendor.Vendor1099 == true)
{
PXUIFieldAttribute.SetEnabled<T5018VendorExt.vendorT5018>(cache, null, isEnabled: false);
PXUIFieldAttribute.SetEnabled<Vendor.box1099>(cache, null, isEnabled: true);
}

 

2 replies

RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+4
  • Acumatica Moderator
  • October 17, 2023

Yuriy Zaletskyy
Jr Varsity I
Forum|alt.badge.img+3

You need to use SetEnabled method of PXUIFieldAttribute. Also make sure, that you use RowSelected event of main DAC class, otherwise, may be ommited from execution ( I don’t know why ). Below goes fragment of Acumatica source code:

 

		protected virtual void Vendor_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
Vendor vendor = (Vendor) e.Row;
T5018VendorExt extension = PXCache<BAccount>.GetExtension<T5018VendorExt>(vendor);
if (vendor.Vendor1099 == true)
{
PXUIFieldAttribute.SetEnabled<T5018VendorExt.vendorT5018>(cache, null, isEnabled: false);
PXUIFieldAttribute.SetEnabled<Vendor.box1099>(cache, null, isEnabled: true);
}