Syntax for Attribute Classes [AX 2012]

An attribute class is any non-abstract class that inherits from the SysAttribute class. An attribute class can extend directly from the SysAttribute class, or it can extend from any descendent of the SysAttribute class.

The SysAttribute class cannot be used as an attribute because it is declared abstract.

You can enable your attribute class to store tailored metadata each time it is used to decorate a class, by having its constructor take parameters. The parameters for the constructor must be literals of the primitive types, such as int or enum or str.

The X++ compiler does not construct an instance of the attribute class. It stores the name of the attribute class, plus the literal values for its constructor. Therefore, if the logic in an attribute constructor would throw an exception, the exception would not be found by decorating a class with the attribute. The exception would be found later when a process looks at a class to see the attribute it is decorated with. That is when the attribute is constructed.

All attribute classes in Microsoft Dynamics AX have the suffix Attribute in their name. The Attribute suffix is the name convention that we recommend, but it is not a system requirement.

A few classes that were added in early versions of Microsoft Dynamics AX might have the Attribute suffix even though they are not attribute classes.

Tip

You can determine whether a class extends directly from SysAttribute by looking at AOT > Classes > TheClassName > classDeclaration > Edit. There you can see whether the code includes extends SysAttribute. Or the class might extend from another class that directly extends SysAttribute.