Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

ClassDoesNotContainMethod

(0) ShareShare
ReportReport
Posted on by 2

Hi All,

I'm trying to add an event handler for ViewEdit mode changed on any standard form, the following code works fine on any custom form, now trying to achieve the same on standard forms, here VendTable.

The simplified version of code is unable to compile:

[ExtensionOf(FormStr(VendTable))]
final class VendTable_Extension
{
    public void OnViewEditModeChanged()
    {
        //DOSomething
    }

    public void init()
    {
        next init();
        this.viewEditModeHelper().EditModeSwitched  = eventhandler(this.OnViewEditModeChanged);
        this.viewEditModeHelper().ViewModeSwitched  = eventhandler(this.OnViewEditModeChanged);
    }

}

This code produces the following compiler error:

Error ClassDoesNotContainMethod: Form 'Dynamics.AX.Application.VendTable' does not contain a definition for method 'OnViewEditModeChanged' and no extension method 'OnViewEditModeChanged' accepting a first argument of type 'Dynamics.AX.Application.VendTable' is found on any extension class. 

When running the same on a custom form, compiler has no issues:

[Form]
public class AAATest extends FormRun
{
    public void OnViewEditModeChanged()
    {
        //DOSomething
    }

    public void init()
    {
        super();
        this.viewEditModeHelper().EditModeSwitched  = eventhandler(this.OnViewEditModeChanged);
        this.viewEditModeHelper().ViewModeSwitched  = eventhandler(this.OnViewEditModeChanged);
    }

}

The only difference I can notice is the use of COC on a standard form versus using a custom form without COC.

Happy to discuss, Thanks

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: ClassDoesNotContainMethod

    I ran into something similar. I solved it by putting the event handler method to a class, rather then directly to the form.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans