Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Call Form method from Button Clicked / "The class FormRun does not contain this method"

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi folks, hope ye are well.

I have read quite a bit on this topic but am failing to succeed.

I have a button under ActionPane/ActionPaneTab/ButtonGroup/myButton

the button has method 'clicked'.

Once clicked I wish to call a method on the Form, myMethod.

In the clicked method i have:

void clicked()
{
    FormRun myForm = element.args().caller();
    myForm.myMethod();
    super();
}


the myMethod() method displayed for me when I hit '.' and I can select it.

On compile it status the "The class FormRun does not contain this method"

Am just a little confused as to why this is not working for me as it seems quiet straight forward.

Any suggestions welcome.

rgds,

K.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Call Form method from Button Clicked / "The class FormRun does not contain this method"

    thank you both.

    yes, by button is on the main simple list form, and my method is under the form.

    element.myMethod() is exactly what i was looking for.

    thanks again.

    Rgds,

  • Denis Macchinetti Profile Picture
    Denis Macchinetti 16,444 on at
    RE: Call Form method from Button Clicked / "The class FormRun does not contain this method"

    Again, you can use the global formHasMethod method in order to test if the method exist.

  • Suggested answer
    Denis Macchinetti Profile Picture
    Denis Macchinetti 16,444 on at
    RE: Call Form method from Button Clicked / "The class FormRun does not contain this method"

    Hi

    If the method coming from the Caller form, you have to declare myform as Object, so:

    Object myForm = element.args().caller();

    myForm.myMethod();

  • Verified answer
    XB Profile Picture
    XB 1,867 on at
    RE: Call Form method from Button Clicked / "The class FormRun does not contain this method"

    Are you on the same form where the method exists?

    so you can call him with reserve word element.

    element.mymethod

    think about formRun is a generic class object and only have default methods.

    if you want to call a method form other forms do something like this.

    in your destiny form

    init:
    this.parmCallerObject(element.args().caller());


    public Object parmCallerObject(Object _callerObject = callerObject)
    {
    if (!prmisDefault(_callerObject))
    {
    callerObject = _callerObject;
    }

    return callerObject;
    }

    //in your destinty form create a method to call method from orig form

    private void callOrigMethod()
    {

    if (formHasMethod(callerObject.owner(), "methodNamefromorigform"))
    {

    }
    }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans