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

Extension methods for FormControl and Form

(0) ShareShare
ReportReport
Posted on by 1,991

Hi,

I created a form extension and added a new button then I created the following class to be able to override clicked method

[ExtensionOf(formControlStr(CaseDetail,AAbtnNewCase))]
final class CaseDetailAA_Extension
{

public void clicked()
{
   //logic
}

name of class is CaseDetailAA_Extension

now if I want to add a new method for the form caseDetail which is AACreateRecord -- similar to the standard createRecord method in this class and call it inside the clicked method, shall I add this new method in this class I created?

[ExtensionOf(formControlStr(CaseDetail,AAbtnNewCase))]
final class CaseDetailAA_Extension
{

public void clicked()
{
   this.aaCreateRecord();
}

public void aaCreateRecord()

{

  //logic
}



OR

shall I create a new class with [ExtensionOf(formlStr(CaseDetail))] and add aaCreateRecord() in it? if that's the case then this class needs to be CaseDetailAA_Extension. Then what should I rename the extension class for the formControl? what's the best practice? would this work  CaseDetailFormControlAA_Extension?

I have the same question (0)
  • Martin Dráb Profile Picture
    239,031 Most Valuable Professional on at

    You have an erxtension of a form control. If you add a method there, it'll be a method of the form control, not of the form that contains the control. You should decide what you actually want.

    If having it in AAbtnNewCase class is sufficient, just do it - then you don't need an extra class with the form extension.

  • .. Profile Picture
    1,991 on at

    Hi Martin,

    but because the standard method createRecord is for the form, so I thought I should do it on form level as well.

    So what you are saying if I'm only going to call it in the form control method then I can keep the method in the control class, correct?

    but let's say I want to create two classes, is this what should I call each class as a best practice?
    CaseDetailAA_Extension  -- for the form  , or shall I call it CaseDetailFormAA_Extension?
    CaseDetailFormControlAA_Extension   
    -- for the control

  • Verified answer
    Martin Dráb Profile Picture
    239,031 Most Valuable Professional on at

    Where the method should be depends on what it does and how it's supposed to be used.

    As far as I know, there are no best practices about how the names should be formed. I find including the type in extensions names useful, because there often are multiple elements with the same name (e.g. table and form). Also, I usually see company prefixes (AACaseDetail...) instead of suffixes.

  • .. Profile Picture
    1,991 on at

    Hi Martin,

    I created the aaCreateRecord in the form extension, but I can't call it from the form control extension

    community.dynamics.com/.../how-to-call-a-method-in-a-form-extension-class-from-a-form-control-extension-class

  • Martin Dráb Profile Picture
    239,031 Most Valuable Professional on at

    Is there anything more that you want to know about the topic of this thread (whether you should add the method to the form control extension or a form extension)? If not, please verify the answer.

  • .. Profile Picture
    1,991 on at

    Hi Martin,

    no thank you but a comment on your last point  "Also, I usually see company prefixes (AACaseDetail...) instead of suffixes."

    The prefix still won't help if the there table and form are named the same. so i think a suffix with the work Form or table  might help more.

    unless you were talking about sth else that i can name the class AASth_Extension or SthAA_Extension

  • Martin Dráb Profile Picture
    239,031 Most Valuable Professional on at

    You misunderstood my reply. The topic of type is covered by the previous sentence ("I find including the type in extensions names useful, because there often are multiple elements with the same name (e.g. table and form").

    The other senstence ("Also, I usually see company prefixes (AACaseDetail...) instead of suffixes.") is about a different topic, but related to your question about best practices.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 659

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 304 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans