web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to extend multiple methods of form

(1) ShareShare
ReportReport
Posted on by

Hello Experts,

How to extend multiple methods of form in one extended class in d365fo. Plz share the some examples of code snippet.
Thanks,
Phani
I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Hi Phani,

    actually it works exactly the same, no matter if you want to extend one or multiple methods.

    All those methods can be added to the same extension class.

    Do you already know how to extend one form method?

    If yes, just add new methods to the same class and you're good to go.

    If you need any example on how to add methods to a class, perhaps you can share your current code and we can help you add new methods.

  • Community Member Profile Picture
    on at

    Hi Nikolaos,

    Thanks for your quick reply.

    Here is the sample code.

    [ExtensionOf(formStr(DirNameAffix))]

    final class DirNameAffix_Extension

    {

       private void SCodeMethod1()

       {

           Info("This is Method Test");

       }

       [FormDataFieldEventHandler(formDataFieldStr(DirNameAffix, DirNameAffix, Affix), FormDataFieldEventType::Modified)]

       public static void Modified(FormDataObject sender,  FormDataFieldEventArgs e)

       {

           Info("Data Field Event test");

           sender.datasource().write();

       }

       //[FormDataSourceEventHandler(formdatasourcestr(DirNameAffix, DirNameAffix),FormDataSourceEventType::Written)]

       //public static void Written(FormDataSource sender, FormDataSourceEventArgs e)

       //{

       //    //Source Code Method

       //    Info("Hi this is test data source");

       //   // next written();

       //}

       [FormDataSourceEventHandler(formdatasourcestr(DirNameAffix, DirNameAffix),FormDataSourceEventType::Written)]

       public static void valiate(FormDataSource sender, FormDataSourceEventArgs e)

       {

           //Source Code Method

           Info("Hi this is test data source");

         //  next written();

         //  return true;

           boolean ret;

                info("Hi this is test data source");

         //  ret = next ValidatedWrite();

             //  return ret;

          // super();  

       }

       //public boolean validateWrite1()

       //{

       //        boolean ret;

       //         info("Hi this is test data source");

       //        //ret = next ();

       //        return ret;

       //}

       //public boolean validateWrite()

       //{

       //    boolean ret;

       //    info("Hi this is test data source");

       //    //ret = super();

       //    return ret;

       //}

       [FormControlEventHandler(formControlStr(DirNameAffix, SaveButton), FormControlEventType :: Clicked )]

       public static void Clicked(FormControl sender, FormControlEventArgs e)

       {

           Info("Hi this is test button11111111");

           // next clicked();

           Info("Hi this is test button");

           //...

           //super();

       }

    }

    when i use super keyword i am getting problem.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Hi Phani,

    seems that you are confusing three things:

    1) Class extension / augmentation / Chain of Command

    2) Class inheritance

    3) Event handlers

    - You can use CoC to add new methods to standard objects, as well as "extend" standard methods.

    - Class inheritance can be used to replace functionality of base class, but you can't use that with D365 forms. Super() is used in class inheritance. NOT in class augmentation / CoC - there you must call next().

    -Event handlers can be used to trigger your code when an event is triggered. But it can't be used to add new methods. Event handlers are not needed very often anymore, instead you can use CoC. Of course you still CAN use event handlers. Anyway those topics are out of scope of your current question. But you can find all the info that you need by searching the web and looking through documentation.

    If you have more questions about these topics, please post new questions.

    Here's a snippet that shows how to add two methods to a form using CoC:

    [ExtensionOf(formStr(DirNameAffix))]
    final class MyDirNameAffix_Extension // Remember to always use your prefix in the name of the class!!!
    {
       public void method1()
       {
    
       }
       
       public void method2()
       {
    
       }
    }

  • ergun sahin Profile Picture
    8,826 Moderator on at
  • Community Member Profile Picture
    on at

    Hi Nikolaos,

    Thanks for your quick reply.

    As you given in the sample code shall I write the below methods in one extension class( form extension class).

    1) Methods on controls.

    2)Methods on data sources.

    3)Methods on fields on data sources

    if yes , please share the sample code snippet for each one.

    Thanks,

    Phani

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Hi,

    each data source and field are actually separate classes, so you need to create separate extension classes.

    We discussed this just 2 days ago: community.dynamics.com/.../how-to-write-the-extension-class-for-existing-forms

  • Community Member Profile Picture
    on at

    Hi Nikolaos,

    Sorry for repeating the same ask again and again,

    suppose if we have 10 fields then do we need to create 10 extension files for below code.

    Please correct us if wrong

    [ExtensionOf(formDataFieldStr(LedgerJournalTansVendPaym, LedgerJournalTrans , LedgerDimension))]

    final class LedgerJournalTransVendPaymFieldLJ_Extension

    {

    }

    Thanks,

    Phani

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    If you want to use Chain of Command in 10 different form data fields, you need to create 10 extension classes.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 733

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 278 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans