Changing caption dynamically using readonly DAC fields.
Introduction#
This example shows how to change dynamically the Caption/Label of Customer Name field on Customer ScreenID AR303000 on Acumatica ERP, depending on current Customer ID selected on the same form. We could:
How-To
Add new unbound field to the DAC. (as readonly)
[PXString(60, IsUnicode = true)]
[PXUIField(Enabled = false, IsReadOnly = true)]
public virtual string UsrReadOnlyAcctName{get;set;}
public abstract class usrReadOnlyAcctName : IBqlField{}
Modify its value depending on conditions using handlers. (On Customer cycle ID Selected)
public class CustomerMaint_Extension:PXGraphExtension<CustomerMaint>
{
protected void Customer_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
var customer = (BAccount)e.Row;
var customerExt = customer.GetExtension<BAccountExt>();
if (customerExt != null)
{
customerExt.UsrReadOnlyAcctName = customer.AcctName;
}
}
}
SuppressLabel(true) for both new unbound fields and existing fields whose label will be replace.
Place the added unbound field before the existing field.
Results: