Skip to main content



No record found.

Dynamics 365 Community / Forums / Finance forum / Apply range on DOMQuery
Finance forum

Apply range on DOMQuery

Posted on by
Hi Community,
I am trying to apply the range on DOMQuery during the DOMProcess Batch Job. I copied the post event handler of getsalesOrderquery method and applying range on salestable. but it did not work.
 [PostHandlerFor(classStr(DOMProcessingHelper), staticMethodStr(DOMProcessingHelper, getSalesOrderQuery))]
    public static void DOMProcessingHelper_Post_getSalesOrderQuery(XppPrePostArgs args)
        SalesTable salesTable   = args.getThis() as SalesTable;
        Query                   query = new Query(queryStr(DOMQuery));
        QueryBuildDataSource    qbdsSalesTable;
        QueryBuildRange qbr;

        qbdsSalesTable = query.dataSourceTable(tableNum(salesTable));
        qbdsSalesTable.fields().addField(fieldNum(SalesTable, SalesId));
        qbr = qbdsSalesTable.addRange(fieldNum(SalesTable, RetailChannelTable));
        QueryRun queryRun = new QueryRun(query);
        while (
            SalesTable salesTableResult = queryRun.get(tableNum(SalesTable));
            info(strFmt(/Retail Channel : %1/, salesTableResult.RetailChannelTable));

  • Martin Dráb Profile Picture
    Martin Dráb 225,549 Super User on at
    Apply range on DOMQuery
    Your extension doesn't change the query used by DOMProcessingHelper class. You just created a completely new query, ran it, added something to infolog... and then let the system continue with its originally query.
    Instead of creating a new query, you'd need to ranges to the query returned by getSalesOrderQuery(). But I see that the whole class is internal, therefore you shouldn't be extending it all. Otherwise it would look like this (let's use CoC instead of PostHandlerFor, because it's both easier to use and safer).
        public static Query getSalesOrderQuery(DOMExecutionContext _domExecutionContext, RecId _softRunSalesRecId)
            // Get the standard query
            Query query = next getSalesOrderQuery(_domExecutionContext, _softRunSalesRecId);
            // Modify the query
            QueryBuildDataSource qbdsSalesTable = query.dataSourceTable(tableNum(SalesTable));
            // Return the modified query
            return query;
    (Moved from Dynamics AX forum.)

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,914 Super User

Martin Dráb Profile Picture

Martin Dráb 225,549 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans