To keep this blog up to date I would like to mention some changes done in code extensibility of D365 for Finance and Operations since my last post about D365FO extensibility, AX7 (D365) Chain of command with examples, in November 2017.

Replaceable keyword

In chain of command method extensions, now you are able to skip calling the base method (next call) by adding “Replaceable” attribute to the base method. This is added by Microsoft because of the high demand from the D365FO community for the ability to suppress the original method call when extending a method using chain of command. This attribute is available from on Platform Update 11.


class Demo
{
    [Replaceable]
    protected void replaceMe(int _i)
    {
         //base call
         error(int2str(_i));
    }
}

[ExtensionOf(classStr(demo))]
final class Demo_Extension
{
    protected void replaceMe(int _i)
    {
        info(int2str(_i));
        //and you do not have to call next!
    }
}

For more information, check the following blog post about the new Replaceable keyword:

http://kashperuk.blogspot.com/2017/10/development-tutorial-extensibility_7.html

Extensions for form datasources, data fields and form controls

From on Platform Update 17, you can extend the methods on form nested objects using the extension syntax shown below :

Form data sources:


[ExtensionOf(formdatasourcestr(DemoForm, DataSource1))]
final class DemoFormDataSource1_Extension
{
    public int active()
    {
        next active();
    }
}

Data source data fields:

[ExtensionOf(formdatafieldstr(DemoForm, DataSource1, Field1))]
final class DemoFormField1_Extension
{
	public boolean validate()
	{
    		boolean ret

    		ret = next validate();
return ret;
        }
}

Form controls:


[ExtensionOf(formcontrolstr(DemoForm, Button1))]
final class DemoButton1_Extension
{
    public void clicked()
    {
        next clicked();
    }
}

For more information, you can check the updated chain of command help from Microsoft :

https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/extensibility/method-wrapping-coc#nested-class-methods-in-forms-can-be-wrapped-in-platform-update-16-or-later

Ability to override forms design pattern from form extensions

From on Platform Update 17, you can change the form design pattern to “Custom” from a form extension, to be able to add your extended controls in a more flexible manner. This solves the problem that you get form pattern related errors when you try to add new extension controls on a form with a fixed, not changeable pattern :

PatternCustom.PNG

 

Leave a Reply