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 :
Finance | Project Operations, Human Resources, ...
Unanswered

How to accessing form query in extension class for init method

(0) ShareShare
ReportReport
Posted on by 309

Hi,

If I want to create extension class or COC for a standard form's Init method, how can we access the form query ?

I tried to use this -> QueryBuildDataSource SalesTableQbds = this.form().query().dataSourceTable(tableNum(SalesTable)); but it is incorrect. I also tried to use keyword "queryBuildDataSource()" but I have no clue how to use it.

The purpose for this extension of Form's init method is to add a new datasource to its original query.

Thank you

I have the same question (0)
  • GirishS Profile Picture
    27,827 Moderator on at

    Hi Axel Cage,

    If you want to add datasource to the form. You can directly extend the form and add a datasource to it.

    Is there any reason for adding datasource to the form via code?

    Thanks,

    Girish S.

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    The easiest way is SalesTable_ds.queryBuildDataSource().

    By the way, please realize that "it is incorrect" says nothing about the actual problem. You should tell us what actually happened. For example, that you got a compilation error, at what place and what the error message said.

    queryBuildDataSource() isn't a keyword. It's a method.

  • Axel Cage Profile Picture
    309 on at

    Yes, I eventually using SalesTable_ds.queryBuildDataSource(), I was in doubt before because the intellisense not working, it won't give me any suggestion. But I'm browsing and found someone  also using this way, so I give it a try. I'm not sure why intellisense not working on this. the "incorrect" is the usual redline underlining my code.

    The reason I'm adding using code is because there is some logic I need to add before adding datasource.

    Thanks

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans