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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How add a method extension in an extension form

(0) ShareShare
ReportReport
Posted on by 160
Hello,
I would like to create an extension form method on an extension form (ProjStatistic.Extension) in the form's methods in order to use it on a standard method  updateButton with a PostHandlerFor.
Is it possible to do this?, or the the syntax does not exist for creating an extension method in form?

/// <summary>
///  PostHandlerFor method of updateButton
/// </summary>
/// <param name="args"></param>
[PostHandlerFor(formStr(ProjStatistic), formMethodStr(ProjStatistic, updateButton))]
public static void ProjStatistic_Post_updateButton(XppPrePostArgs args)
{

// element.MySpecificExtensionMethod // How use an form extension method from the extension form?

}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,002 Most Valuable Professional on at
    RE: How add a method extension in an extension form

    To seemingly add new methods, use class extensions. Yes, it works with forms as well, you'll just use [ExtensionOf(formStr(ProjStatistic))]. You can see an example in Code behind extension forms: How to add state variables and override methods without overlayering.

  • Foxsor Profile Picture
    160 on at
    RE: How add a method extension in an extension form

    Thank Martin.

    I could not use variables in form extension:

    [ExtensionOf( formstr( ProjStatistic )) ]

    final class ProjStatistic_Extension

    {

       public real xxxCalc;

       public static void xxxlCalc)

       {

          xxxCalc = 10;

       }

       /// <summary>

       ///

       /// </summary>

       /// <param name="args"></param>

       [PostHandlerFor(formStr(ProjStatistic), formMethodStr(ProjStatistic, updateButton))]

       public static void ProjStatistic_Post_updateButton(XppPrePostArgs args)

       {

       }

    I think my AX version (Platform1) did not support variables in form extension:

    "Fields on an extension class is only supported if the ExtensionOf attribute is used on a class."

  • Martin Dráb Profile Picture
    237,002 Most Valuable Professional on at
    RE: How add a method extension in an extension form

    It's possible; I don't gave the one-year-old version to test it.

    Note that the support for Platform Update 1 ends in less than three weeks, so you should upgrade very soon anyway.

  • Foxsor Profile Picture
    160 on at
    RE: How add a method extension in an extension form

    Thank Martin.

  • KevinGroves Profile Picture
    30 on at
    RE: How add a method extension in an extension form

    Make the post_updateButton method none static and it should work.

  • Community Member Profile Picture
    on at
    RE: How add a method extension in an extension form

    Hi Foxsor, Can you resolve the problem? I have a similar problem, but I can not solve it, in case you could share your solution, I would appreciate it, Regards

  • Martin Dráb Profile Picture
    237,002 Most Valuable Professional on at
    RE: How add a method extension in an extension form

    You should rather create a new thread and explain your specific problem.

  • Giridhar1617 Profile Picture
    on at
    RE: How add a method extension in an extension form

    Hi Martin,

    I have added a new method in the form using class extension. In the place where i am calling it, I would like to have a check if the formHasMethod and call the method using formRun object. Is it possible? When I try this, it says method does not exist on the form, actually it is existed on the underlying class extension. Can you please help me out how to solve this scenario?

    Regards,

    Giridhar

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Willem van Duren Profile Picture

Willem van Duren 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans