Customization of Field Attributes in DAC Extensions

If you have a customization that replaces the original attributes of a field with custom attributes, after you upgrade MYOB Acumatica to a new version, new functionality may became unavailable, as the following diagram shows.

Figure 1. Possible result of using the Replace (default) method to customize the attributes of a DAC field


To address this issue, the customization framework provides advanced possibilities for you to control the field customization by using additional attributes in the DAC extension.

When you customize MYOB Acumatica, you can specify how the system should apply the original and custom attributes to the field. Thus, you can make the customizations more flexible and use the collections of original attributes that could be updated between MYOB Acumatica versions.

To specify the way the system should apply the field attributes in a DAC extension, you can use the following attributes.
Attribute Description
PXMergeAttributes Specifies how to apply custom attributes to the existing ones.
PXRemoveBaseAttribute Removes the specified existing attribute.
PXCustomizeBaseAttribute Defines a new value for the specified attribute parameter.
PXCustomizeSelectorColumns Defines the new set and order of the columns in the selector.

In the following example, the display name of the MyField field of the MyDac DAC is My Field, and in the MyDacExt DAC extension the display name of this field is changed to My Custom Field.

public class MyDac : PXBqlTable, IBqlTable
{
   public abstract class myField: PX.Data.BQL.BqlInt.Field<myField> { }
   [PXDBInt]
   [PXUIField(DisplayName = "My Field")]
   public virtual int? MyField{ get; set; }
}

public class MyDacExt : PXCacheExtension<MyDac>
{
  [PXCustomizeBaseAttribute(typeof(PXUIField), 
        nameof(PXUIFieldAttribute.DisplayName), "My Custom Field)]
  [PXMergeAttributes(Method = MergeMethod.Append)]
  public virtual int? MyField{ get; set; }
}

Application Order of the Custom Attributes

The customization attributes described above are applied in the following order:

  1. PXCustomizeBaseAttribute
  2. PXRemoveBaseAttribute
  3. PXMergeAttributes
Note: The PXCustomizeSelectorColumns works independently of these three attributes.

For details on how to customize field attributes for a particular screen, see the Overriding Attributes of a DAC field in the Graph topic.

Adding Attribute to Existing DAC Field

Suppose that you have a DAC and a DAC extension, and in a DAC extension, you need to add an attribute to the set of inherited attributes of a DAC field. In that case, you will need to override the whole property including the virtual field and the abstract class and define all attributes from scratch. The customization attributes described in the previous section, are not applicable.

In case of an auto-implemented property in the parent DAC, define the auto-implemented property in the DAC extension. In case of a full property in the parent DAC, define the full property in the DAC extension. For example, suppose that you have the following property in the parent DAC.

public virtual int? MyProp
{
    get => _FieldValue;
    set => _FieldValue = value;
}

The overridden property should looks as shown in the following code.

public override int? MyProp
{
    get => base.MyProp;
    set => base.MyProp = value;
}