web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Apply range on DOMQuery

(1) ShareShare
ReportReport
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));
        qbr.value(/5632076/);
        QueryRun queryRun = new QueryRun(query);
        while (queryRun.next())
        {
            SalesTable salesTableResult = queryRun.get(tableNum(SalesTable));
            info(strFmt(/Retail Channel : %1/, salesTableResult.RetailChannelTable));
        }

    }
I have the same question (0)
  • Martin Dráb Profile Picture
    240,055 Most Valuable Professional on at
    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).
    [ExtensionOf(classStr(DOMProcessingHelper))]
    {
        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.)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
Subra Profile Picture

Subra 386

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 382 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 270 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans