Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Get Form datasource method in class extension

Posted on by Microsoft Employee

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

  • Suggested answer
    Prabakaran.R Profile Picture
    Prabakaran.R 305 on at
    RE: Get Form datasource method in class extension

    Hi Arun,

    You can use like that,

    [FormDataFieldEventHandler(formDataFieldStr(InventTransferOrders, InventTransferLine, QtyTransfer), FormDataFieldEventType::Modified)]
    public static void QtyTransfer_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {

    FormDataSource inventTransferLine_ds = sender.datasource();

    InventTransferLine inventTransferLine = inventTransferLine_ds.cursor();

    inventTransferLine .initvalue();

    }

    Thanks,

    Prabakaran R.

  • Suggested answer
    Sukrut Parab Profile Picture
    Sukrut Parab 71,647 Moderator on at
    RE: Get Form datasource method in class extension

    try this

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

    FormDataSource ForecastSales_ds = = formRun.dataSource(ForecastSales')

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get Form datasource method in class extension

    In First line also i m getting error:

    i just wrote the two lines of code.

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,647 Moderator on at
    RE: Get Form datasource method in class extension

    which line you are getting this error ?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get Form datasource method in class extension

    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
    Sukrut Parab 71,647 Moderator on at
    RE: Get Form datasource method in class extension

    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
    Community Member Microsoft Employee on at
    RE: Get Form datasource method in class extension

    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
    Sukrut Parab 71,647 Moderator on at
    RE: Get Form datasource method in class extension

    Answer is already given . Did you check my reply ?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get Form datasource method in class extension

    D 365

  • Suggested answer
    Sukrut Parab Profile Picture
    Sukrut Parab 71,647 Moderator on at
    RE: Get Form datasource method in class extension

    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.

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans