Class Extension D365FO
In this blog I will show you class extension in D365 and add new method in the existing class without any over-layer..
There are two way to create Extension of the existing class...
- Static Class
- ExtensionOf
Static class
Create a new public static class use the name pattern ClassName + _Extension
You can use the following code for reference....
public static class SLD_PaymFee_Extension
{
public static void paymfeeFind(PaymFee _this)
{
/// You can write your code here
_this.findFees(); //Use _this to call
methods from the base class;
}
}
ExtensionOf
Create new class add the annotation of ExtensionOf and enter the class name... In this type of extension add final keyword.
[ExtensionOf(classStr(PaymFee))]
final class SLD_PaymFee_Extension
{
public static void paymfeeFind(PaymFee _this)
{
/// You can write your code here
_this.findFees(); //Use _this to call
methods from the base class;
}
}
For verification you can use the below code
class SLD_DemoClass
{
public static void main(Args _args)
{
PaymFee obj =new PaymFee();
obj.paymfeeFind();
}
}
No comments:
Post a Comment