Class Extension D365FO



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...


  1. Static Class 
  2. 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();
    }

}


Support Faryal's Cusine


Label Extension D365FO

Label Extension  D365FO



As We, All know Label Extension is not available in D365FO in the same way we use to create form, Table, and class Extension...


You can check the below screenshot Label extension option is gray/disable in the menu.



What is the resolution?

There is a way to create an extension of Existing label files.
Add a new label file like the below image... In my demo, I am Creating an Extension of the Sys Label file. 

In Extension use Prefix of Existing Label File name then Add _Extension as Postfix




In my case file name was Sys_Extension. Now click on Add button and complete the wizard.


Select the Language is in use by Parent Label file and click on next ...



You can create a new Label and override the existing one, For Demo purposes, I have created Two Labels @SYS456 which is New Label, and the second I created @SYS12 which is already Exists in SYS Label File... We created this one to override the existing Label.





Now I have created a Menu Item and assign the @SYS456 Label to Menu Items...





To handle the Override case, I have created a class for the verification...

class SLD_DemoClass
{

     
        public static void main(Args _args)
    {
   
        info(SysLabel::labelId2String2(literalstr('@SYS12'), 'en-US'));
        info(SysLabel::labelId2String2(literalstr('@SYS456'), 'en-US'));
    }

}




Support Faryal's Cusine


Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...