Skip to main content

Notifications

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

  • Suggested answer
    Prabakaran.R Profile Picture
    311 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
    71,682 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
    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
    71,682 Moderator on at
    RE: Get Form datasource method in class extension

    which line you are getting this error ?

  • Community Member Profile Picture
    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
    71,682 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
    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
    71,682 Moderator on at
    RE: Get Form datasource method in class extension

    Answer is already given . Did you check my reply ?

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

    D 365

  • Suggested answer
    Sukrut Parab Profile Picture
    71,682 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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,998 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,850 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans