web
You’re offline. This is a read only version of the page.
close
Skip to main content
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,019

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 !

I have the same question (0)
  • Suggested answer
    ergun sahin Profile Picture
    8,824 Moderator on at
    RE: I have an AOT Query, Can I Show The Count of its records in a Static Text Form Control?

    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,019 on at
    RE: I have an AOT Query, Can I Show The Count of its records in a Static Text Form Control?

    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,019 on at
    RE: I have an AOT Query, Can I Show The Count of its records in a Static Text Form Control?

    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
    RE: I have an AOT Query, Can I Show The Count of its records in a Static Text Form Control?

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,004

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 548 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans