Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Why does my FormDataSource not recognize its method

(0) ShareShare
ReportReport
Posted on by 191

[ExtensionOf(formDataSourceStr(PurchTable, PurchTable))]
internal final class FM_Datasource_PurchTable_PurchTable_Extension
{
    [FormDataFieldEventHandler(formDataFieldStr(PurchTable, PurchTable, CurrencyCode),FormDataFieldEventType::Modified)]
    public static void onModified_CurrencyCode(FormDataObject _dataObject, FormDataFieldEventArgs _args)
    {
        _dataObject.datasource().modified_CurrencyCode();
    }

    public void modified_CurrencyCode()
    {
        str x = 'test';
    }

}

I simply added an eventHandler where I call the method that I added to the class myself, but the compiler does not recognize the modified_CurrencyCode method and returns as error:

Error ClassDoesNotContainMethod: Class 'FormDataSource' does not contain a definition for method 'thisIsATest' and no extension method 'thisIsATest' accepting a first argument of type 'FormDataSource' is found on any extension class.

Does anyone know what could cause this issue?

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Why does my FormDataSource not recognize its method

    Hi SuperBunny,

    Don't combine event handler and COC in one class. It will be better if you create separate class.

    For the issue try assigning the sender to Object and then call the datasource method.

    [ExtensionOf(formDataSourceStr(PurchTable, PurchTable))]
    internal final class FM_Datasource_PurchTable_PurchTable_Extension
    {
        [FormDataFieldEventHandler(formDataFieldStr(PurchTable, PurchTable, CurrencyCode),FormDataFieldEventType::Modified)]
        public static void onModified_CurrencyCode(FormDataObject _dataObject, FormDataFieldEventArgs _args)
        {
            Object purchTable = _dataObject;
            purchTable.modified_CurrencyCode();
        }
    
        public void modified_CurrencyCode()
        {
            str x = 'test';
        }
    
    }

    Thanks,

    Girish S.

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,111 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,934 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans