I'm trying to dynamically change the display name of a DAC extension field based on another field value in the same extension, but PXUIFieldAttribute.SetDisplayName() does not update the UI even though the code executes.
DAC Extension:
public class LocationExt : PXCacheExtension<PX.Objects.CR.Standalone.Location>
{
#region UsrGSTRegistration
[PXDBString(16)]
[PXUIField(DisplayName = "GST Registration")]
public virtual string UsrGSTRegistration { get; set; }
public abstract class usrGSTRegistration :
PX.Data.BQL.BqlString.Field<usrGSTRegistration> { }
#endregion
}
Inside RowSelected:
PXUIFieldAttribute.SetDisplayName<LocationExt.usrGSTRegistration>(
e.Cache,
displayName);
The code compiles correctly, the event hits during debugging, and displayName gets the expected value — but the label in the UI does not change.
As a workaround suggested in another post in this community, I tried creating an unbound field to act as a dynamic label:
#region UsrReadOnlyGSTRegistrationLabelName
[PXString(32)]
[PXUIField(DisplayName = "GST Registration Label Name")]
public virtual string UsrReadOnlyGSTRegistrationLabelName { get; set; }
public abstract class usrReadOnlyGSTRegistrationLabelName :
PX.Data.BQL.BqlString.Field<usrReadOnlyGSTRegistrationLabelName> { }
#endregion
Then I set its value conditionally and displayed it near the field while hiding the original label. Functionally it works, but the alignment and font styling differ because it is actually rendered as a value field, not a real label.
My questions:
-
Why does
PXUIFieldAttribute.SetDisplayName()not update the UI even though it is an inbuilt framework method? -
Is there a proper supported way to dynamically change a field display name in Acumatica?
Any guidance or recommended approach would be appreciated.