AX / D365FO – How to test the Query syntax and results of a Query

Have you created an AOT Query and want to check if the syntax is correct and the results are what you expected?

You can create a Runnable class like show below

class TestQuery
    public static void main(Args _args)
        Example job used to test query results with.:

        QueryRun queryRun;
        Counter totalRecords;

        // Table Variables:

        VendTable vend;
        VendCertification VendCert;

        queryRun = new QueryRun(queryStr(...your Query name here..));

        if (queryRun.prompt()) //Here the query prompt will open, if you want you can change the filters
            while (
                vend = queryRun.get(tableNum(VendTable));

                VendCert = queryRun.get(tableNum(VendCertification));


        info(strFmt("Total Records : %1", totalRecords));

When you debug the code you can check the Query syntax by watching inside the queryRun variable

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s