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

Community site session details

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

D365FO On adding via x++ a new DS to dynamic query (with more than 1 DS's), the query becomes empty

(0) ShareShare
ReportReport
Posted on by 5
Hello,
 
I have a dynamic query (selections entered by the user), which is stored via query.pack() in a table field. At some later point in time - this table record needs to be processed and I need to add some extra conditions to the query – e.g. adding an non-existing join clause to another (not initially available in the query) table. This seems to work if the initial query is based only on ONE table, but if the initial query is a join of multiple tables, adding a new data source to the query “clears” the initial query. For exmample, if the initial oldQuery  (with CustInvoiceJour as the first data source) - consists only of the CustInvoiceJour data source - the adding of the new data source works. But if the initial oldQuery has e.g. also SalesTable joined to the CustInvoiceJour - the adding of a new data source seems to "break":
 
  newQuery = new Query (oldQuery.pack());                                              // cloning of the old query
  qbdsCIJ    = newQuery.dataSourceTable(tableNum(CustInvoiceJour));    //  data source found
  qbdsNSN  = qbdsCIJ.addDataSource(tableNum(NSNProcessed));          //  here the newQuery gets "empty" - with only the new NSNProcessed table as a datasource
  qbdsNSN.relations(true);
  qbdsNSN.joinMode(JoinMode::NoExistsJoin);
  qbdsNSN.addRange(fieldNum(NSNProcessed, WorkRequest)).value(queryValue(WorkReqNo));
 
any ideas?
Thank you!
 
Categories:
I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 722 Most Valuable Professional

#2
CU05031448-0 Profile Picture

CU05031448-0 614

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 609 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans