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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get Form datasource method in class extension

(0) ShareShare
ReportReport
Posted on by

Hi All,

How to get the form datasource method in modified eventhandler in class extension.

Please help me.

Thanks for your valuable reply.

*This post is locked for comments

I have the same question (0)
  • Sebastian Mankowski Profile Picture
    305 on at

    What version of Dynamics you are talking about? 365 or AX 2012 R3? You tagged it as AX but there is no class extensions in AX.

  • Suggested answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    You can get formDatasource from sender as shown below

    FormDataSource projTable_ds = sender.formRun().dataSource("ProjTable");

    another way is

    FormDataSource MyRandomTable_ds = sender.dataSource(formDataSourceStr(SomeForm, MyRandomTableDS)

    Once you have formDatasource you can easily access its methods.

  • Community Member Profile Picture
    on at

    D 365

  • Sukrut Parab Profile Picture
    71,710 Moderator on at

    Answer is already given . Did you check my reply ?

  • Community Member Profile Picture
    on at

    Hi Sukrut,

    Thanks for your reply.

    I already tried your suggestion but i cant able to call the datasource method.

    please help.

    Thanks

    Arun Joseph A

  • Sukrut Parab Profile Picture
    71,710 Moderator on at

    once you get the datasource just put datasource_ds.yourMethodname() . It doesn't show your method when you indent  but it works

  • Community Member Profile Picture
    on at

    Thanks for reply.

    Its throw error to me.

    This is my scenario:

    FormDataFieldEventHandler(formDataFieldStr(ForecastSales, ForecastSales, Currency), FormDataFieldEventType::Modified)]

       public static void Currency_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

       {

         FormDataSource ForecastSales_ds =

         sender.datasource(formDataSourceStr(ForecastSales, ForecastSales));

         ForecastSales_ds.updateAmount();

        }

    its throw error FormDataObject.datasource,expect 0 arguments,but 1 specified

  • Sukrut Parab Profile Picture
    71,710 Moderator on at

    which line you are getting this error ?

  • Community Member Profile Picture
    on at

    In First line also i m getting error:

    i just wrote the two lines of code.

  • Suggested answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    try this

    FormRun formRun = _sender.datasource().formRun();

    FormDataSource ForecastSales_ds = = formRun.dataSource(ForecastSales')

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans