John
John

Reputation: 773

Change label name of default fields

I want to show which user created Invoice, for this i have added default Acumatica field, but the label is showing as Created By, how can i change that label name to "Invoice Created By". Please have a look at below screenshot for field am referring to. enter image description here

Upvotes: 0

Views: 757

Answers (2)

DChhapgar
DChhapgar

Reputation: 2340

You could use PXUIFieldAttribute.SetDisplayName static method to change DAC field’s display name. This change will be applicable only for Sales Invoice Entry Graph (SO303000 screen)

public class SOInvoiceEntryPXDemoExt : PXGraphExtension<SOInvoiceEntry>
{
    public override void Initialize()
    {
        PXUIFieldAttribute.SetDisplayName<ARInvoice.createdByID>(Base.Document.Cache, "Invoice Created By");
    }
}

If you need display name changed for this field in all screens, you need to have DAC Extension as below:

With this, attributes specified in an extension DAC apply to DAC class in every Graph of the application unless a Graph replaces them with other attributes.

public class ARInvoicePXDemoExt : PXCacheExtension<ARInvoice>
{
    [PXMergeAttributes(Method = MergeMethod.Append)]
    [PXUIField(DisplayName = "Invoice Created By", Enabled = false, IsReadOnly = true)]
    public virtual Guid? CreatedByID { get; set; }
}

You need to add CreatedByID field on screen SO303000

enter image description here

And set DisplayMode property to Text.

enter image description here

Upvotes: 4

Joshua Van Hoesen
Joshua Van Hoesen

Reputation: 1732

The 'CreatedByID' I believe is an audit field and therefore cannot easily change the ui of the additional data fields available through the control. The resolution I would suggest is a non database backed UI field that is populated during row selecting. Example can be found below :

public class SOOrderEntryExtension : PXGraphExtension<SOOrderEntry>
{
    public virtual void SOOrder_RowSelecting(PXCache sender, PXRowSelectingEventArgs e)
    {
        SOOrder row = e.Row as SOOrder;
        if(row != null)
        {
            SOOrderExtension rowExt = PXCache<SOOrder>.GetExtension<SOOrderExtension>(row);

            Users user = PXSelectReadonly<Users, Where<Users.pKID, Equal<Required<Users.pKID>>>>.Select(this.Base, row.CreatedByID);
            if(user != null)
            {
                rowExt.InvoiceCreatedBy = user.DisplayName;
            }
        }
    }
}

public class SOOrderExtension : PXCacheExtension<SOOrder>
{
    public abstract class invoiceCreatedBy : PX.Data.IBqlField
    {
    }
    [PXString]
    [PXUIField(DisplayName = "Invoice Created By")]
    public virtual string InvoiceCreatedBy { get; set; }
}

Upvotes: 0

Related Questions