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 Advanced 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 Advanced, 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 Advanced 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 : 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.