In this post I want to show how chain of command can replace pre- or post-events.
After having created / opened the desired project, you can create a new object of type Class via the context menu of the project under Add > New item. Now you should rename your class, important here is the extension _Extension.
After that, a simple class is available that presents itself as follows
class FMCustomer_DMO_Table_Extension
{
}
Now we change the class via the ExtensionOf attribute and add the final modifier. Classes identified in this way are also referred to as augmentation classes.
[ExtensionOf(tableStr(FMCustomer))]
final class FMCustomer_DMO_Table_Extension
{
}
Now we switch back to the Application Explorer, look for the table we want to expand there and expand the Methods node. Now for the respective method, in the example the insert(), and select the option View Code via the context menu.
This opens the method in the workspace from which we copy the definition of the method to the clipboard.
public void insert()
{
}
We insert this code in the extension class.
Then we insert the call of the original method into our code
[ExtensionOf(tableStr(FMCustomer))]
final class FMCustomer_DMO_Table_Extension
{
public void insert()
{
next insert();
}
}
Then you can insert the appropriate code before calling next() or after this call. Depending on the position of this code, we have realized a pre- or post-event handler.
Im konkreten Beispiel wird vor dem Aufruf der Original insert()-Methode ein Feld ggf. mit einem Standardwert befüllt.
[ExtensionOf(tableStr(FMCustomer))]
final class FMCustomer_DMO_Table_Extension
{
public void insert()
{
if ( !this.Email)
{
this.Email = "someone@somewhere.com";
}
next insert();
}
}
This article was created based on version 7.3 with Platform-Update 12 and installed Fleet Management Sample Application.
These post applies to following version: Dynamics 365 for Finance and Operations
In this post I want to show how chain of command can replace pre- or post-events.
After having created / opened the desired project, you can create a new object of type Class via the context menu of the project under Add > New item. Now you should rename your class, important here is the extension _Extension.
After that, a simple class is available that presents itself as follows
Now we change the class via the ExtensionOf attribute and add the final modifier. Classes identified in this way are also referred to as augmentation classes.
Now we switch back to the Application Explorer, look for the table we want to expand there and expand the Methods node. Now for the respective method, in the example the insert(), and select the option View Code via the context menu.
This opens the method in the workspace from which we copy the definition of the method to the clipboard.
We insert this code in the extension class.
Then we insert the call of the original method into our code
Then you can insert the appropriate code before calling next() or after this call. Depending on the position of this code, we have realized a pre- or post-event handler.
Im konkreten Beispiel wird vor dem Aufruf der Original insert()-Methode ein Feld ggf. mit einem Standardwert befüllt.
This article was created based on version 7.3 with Platform-Update 12 and installed Fleet Management Sample Application.