Dynamics 365 Finance Extension Class

Create an Extension Class

Question

You are a Dynamics 365 Finance developer.

You need to create an extension class.

Which action should you perform?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

A.

Extension classes are final classes that are adorned with the ExtensionOf attribute and that also have a name that has the _Extension suffix.

https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/extensibility/class-extensions

In Dynamics 365 Finance and Operations, an extension class is used to add new functionality or modify existing functionality of an existing class without modifying the original class. This approach helps to maintain the original code as it is and provide flexibility to customize the behavior of the application.

To create an extension class in Dynamics 365 Finance and Operations, the following steps should be performed:

  1. Create a new class and define the methods that need to be added or modified.
  2. Decorate the class with the ExtensionOf attribute.
    • Answer A is the correct action to perform, as this attribute identifies the original class that the extension class is extending.
    • The ExtensionOf attribute takes the name of the original class as a parameter, like [ExtensionOf(classStr(OriginalClass))]
  3. To modify the behavior of the original class, override the methods of the original class in the extension class.
    • This is done by creating a new method with the same name and signature as the original method in the extension class.
  4. To add new functionality to the original class, create new methods in the extension class.

In addition to decorating the class with the ExtensionOf attribute, there are some other guidelines that should be followed when creating an extension class in Dynamics 365 Finance and Operations:

  • The extension class should have the same access level as the original class.
  • The extension class should be in the same model as the original class.
  • The extension class should have the same name as the original class, with the suffix "Extension".
  • The extension class should be decorated with the SysExtensionAttribute attribute.

Regarding the other answer options:

  • Answer B is incorrect, as adding the class buffer as the first parameter is a technique used to create a class extension method, not an extension class.
  • Answer C and D are incorrect, as the access level of the class is not relevant when creating an extension class. However, it's recommended to keep the class as public to avoid any conflicts with access levels.