Alfredo Ibarra
Alfredo Ibarra

Reputation: 73

How to change the Display Name for one of the PXSelector fields

I need to change the Display Name to "Primary Vendor" for a BAccount.acctName field, which is the last field to display in the PXSelector that I have created. I have tried creating an field Extension which does the trick, but this option also renames the field for another inquiry page, therefore I cannot use it.

The following is my code:

Selector

[PXNonInstantiatedExtension]
public class SO_SOLine_ExistingColumn : 
PXCacheExtension<PX.Objects.SO.SOLine>
{
    #region InventoryID 
    [PXMergeAttributes(Method = 
    MergeMethod.Append)]

[PXSelector(typeof(Search2<InventoryItem.inventoryCD, 
            LeftJoin<BAccount, On<BAccount.bAccountID, 
                Equal<InventoryItem.preferredVendorID>>>,
        Where<InventoryItem.descr, IsNotNull>>),
        typeof(InventoryItem.inventoryID),
        typeof(InventoryItem.inventoryCD),
        typeof(InventoryItem.descr),
        typeof(InventoryItem.postClassID),
        typeof(InventoryItem.itemStatus),
        typeof(InventoryItem.itemType),
        typeof(InventoryItem.baseUnit),
        typeof(InventoryItem.salesUnit),
        typeof(InventoryItem.purchaseUnit),
        typeof(InventoryItem.basePrice),
        typeof(BAccount.acctName), ValidateValue = false) ]

        public int? InventoryID { get; set; }
        #endregion
}

Field Extension

public class BAccountExt : PXCacheExtension<PX.Objects.CR.BAccount>
{

    #region UsrCustomField
    [PXDBString(250, IsUnicode = true, BqlField = 
    typeof(BAccountR.acctName))]
    [PXUIField(DisplayName = "Primary Vendor")]
    public virtual string AcctName { get; set; }
    public abstract class acctName : IBqlField
    {
    }
    #endregion

}

Upvotes: 0

Views: 522

Answers (2)

John
John

Reputation: 773

you can also try like below but this is limited to the specific graph.

  public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
  {
     public override void Initialize()
    {
      PXUIFieldAttribute.SetDisplayName<Customer.acctName>(Base.BAccount.Cache, "Primary Vendor");
    }
  }

Upvotes: 0

Hugues Beaus&#233;jour
Hugues Beaus&#233;jour

Reputation: 8278

As you found out the cache extension modifications applies to all screens who use that DAC. There is another extension mechanism applied on a per graph basis called CacheAttached that is applied after the cache extension.

To use it first you need to identify the graph of the screen you want to customize and the DAC field you want to modify. You can use the inspect element feature for this. In this example the graph for Customers screen is 'CustomerMaint' and the DAC field is 'Customer.acctName': enter image description here

Once you have that information you can create an extension for that graph and extend the DAC field inside it. DAC field extensions defined in the graph using the CacheAttached method will only apply to screens who uses that graph:

public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{
    [PXMergeAttributes(Method = MergeMethod.Merge)]
    [PXUIField(DisplayName = "Display Name For Customers Graph")]
    public virtual void Customer_AcctName_CacheAttached(PXCache sender) 
    {
    }
}

The prototype convention for CacheAttached extensions is:

void DAC_DACField_CacheAttached(PXCache sender) { }

You change DAC and DACField to the field you are targeting. Method definition (body) should remain empty. The attributes decorating the CacheAttached method will apply to the field you're customizing. With attribute PXMerge you can tweak how the CacheAttached extension is applied, it allows to merge the field new attributes of the extension with the base one or completely replace the base attributes.

For more details look at this blog post:

http://asiablog.acumatica.com/2017/01/append-and-replace-of-dacs-attributes.html

Upvotes: 2

Related Questions