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 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).
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.
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...?
Hi
The person is explaining the same In the below thread.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 2,004
André Arnaud de Cal... 857 Super User 2025 Season 2
Sohaib Cheema 548 User Group Leader