Thursday 19 November 2020

Dynamic AX7 / D3FO: Adding display method

 Hi Folks :)

Today we will be looking at how we can add display method on forms.
Let’s say I would like to add a new display method on CustTable form.
In Dynamics 365 we won’t be able to add the new method or modify the existing method to the standard table or to an extension table.
It can be achieved by using the extension class.
Step 1: Create a new class and name it as <Classname>_<Extension>.
[ExtensionOf(tableStr(CustTable))]
public static class CustTable_Extension
{
}
Step 2 : Now add the display methods in the class which is required to be shown.
public static class CustTable_Extension
{
    [SysClientCacheDataMethodAttribute(true)] //This attribute will cache your display method.
    public static display Name customerGroupName(CustTable _this)
    {
        return CustGroup::find(_this.CustGroup).Name;
    }
 }

To use your display method on the form, create your new field on the form extension and use the property as below:




To cache your display method on the form set on the field the property “Cache Data Method” = yes if you don’t want to use the Attribute above.
 















**Things to remember**
·         The class must be postfixed with “_extension”.
·         The class must be static.
·         The extension methods must be static.
·         The type of the first parameter determines which type is extended.

No comments:

Post a Comment