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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

I have an AOT Query, Can I Show The Count of its records in a Static Text Form Control?

(1) ShareShare
ReportReport
Posted on by 1,054

Hello dears!

I have an AOT query which is a Union query.

Can I get the count value of this AOT query to use the value in a static text form control in a form?

Or I have to write the query as a select statement to get the count and use it on static text form control?

Any advice is appreciated !!!

Thanks in advance !

  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    I don't think the union query is a special case. I haven't tried it, but I think you can get the number of records from the QueryRun object if your fields, relations are correct.

    In the examples, he created a query with x . Some rows are not needed as we have AOT query. You can directly use query and queryRun objects

    query       = new Query(queryStr(MyAOTQuery));
    queryRun    = new QueryRun(query);

    community.dynamics.com/.../count-records-in-query-vs-cound-loops-in-query

    I don't know the number of records in the respective tables, but you can make testing easier by adding a simple range (to shrinking the solution set).

  • Momochi Profile Picture
    1,054 on at

    Hi Ergün,

    Using the SysQuery::CountLoops(qr) or SysQuery::CountTotals(qr) gives me an error with the union query.

    The error says:

    "There is a field number mismatch in union query. The field number of Table1 is different than the field number of Table2."

    And I get this error 10 times since there are 10 datasources in the union query.

    I'm using the same query on a grid in a form it works fine. The number of fields for each datarouce do match.

  • Momochi Profile Picture
    1,054 on at

    It worked out to create a while(qr.next()) loop and using an integer variable to count the loop.

    But I'm not sure if there is a better way to implement this...?

  • Suggested answer
    Sheikh Sohail Profile Picture
    6,125 on at

    Hi

    The person is explaining the same In the below thread.

    community.dynamics.com/.../count-records-in-query-vs-cound-loops-in-query

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 426 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 358

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 353 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans