How to Execute a Modelled Query

by | Feb 5, 2014 | Development, Dynamics AX

In AX in the AOT there is a Queries node.  Within the Queries node are many different queries used primarily by services, reports, and list pages.  The queries are modelled queries becaues they have been defined/designed previously and are now saved in the AOT.  They are not dynamically built and executed at run-time.  The modelled queries differ from a table in that you cannot right-click on them in the AOT, choose Open and have AX execute and return the results of the query.  Instead, you can call them programmatically to see their results.  Below is an example of how to execute a modelled query to see what it is returning.  In my example I will execute the Cust query and retrieve the CustTrans and CustTable records.

static

void executingAModelledQuery(Args _args)

{

QueryRun queryRun;

CustTable custTable;

CustTrans custTrans;

queryRun = new QueryRun(queryStr(Cust));

while(queryRun.next())

{

custTable = queryRun.get(tableNum(CustTable));

custTrans = queryRun.get(tableNum(CustTrans));

     print custTable.RecId;

     print custTrans.RecId;

}

pause;

}

Related Posts

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events

july

29jun(jun 29)8:00 am06jul(jul 6)5:00 pmMicrosoft Dynamics GP Core Financials Bootcamp

07jul1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Bringing It All Together

08jul10:00 am11:00 amOn the Job with Dynamics 365 - Manufacturing Planner

08jul2:00 pm2:30 pmHow Ag Retailers and Ag Coops Should Structure IT Resources for the Future

16jul11:00 am12:00 pmConfab with Stoneridge - Livestream - Business Intelligence Power Hour

22jul10:00 am11:00 amOn the Job with Dynamics 365 - Manufacturing Material Handler

22jul12:00 pm1:00 pmImprove Field Service Delivery and Increase Customer Satisfaction

august

05aug10:00 am11:00 amOn the Job with Dynamics 365 - Manufacturing Shipping / Receiving Department

05aug12:00 pm1:00 pmHow Ag Retailers Can Simplify Processing Equity Payments using Levridge

12aug10:00 am10:30 amWhy Levridge Grain? How to Achieve Efficient and Accurate Scale Tickets

12aug12:00 pm1:00 pmThe Three Paths to Dynamics 365 Finance and Supply Chain from Dynamics AX

13aug11:00 am12:00 pmConfab with Stoneridge - Livestream - Dynamics 365 2020 Wave 2 Review

19aug10:00 am11:00 amWhat is Levridge? An Overview of the Ultimate Ag Solution

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X