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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Union in AX 2012

(0) ShareShare
ReportReport
Posted on by

Hi All,

I have an issue making union, I have the table A that has 2 different joins with the other tables; I want to make the same query in the table 2 but the difference is the one join is "NotExists", when I try to union the 2 queries with this sentence:

qr.queryType(QueryType::Union);

and I run the form, the infolog shows me this error:

The join mode in union query is invalid. For a join query, the join mode of the second level data source must be either exists or notexists.

I read in other forums, the UNION doesn't work with joins. Someone can help me to solve the issue using UNION or similar?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Hi Eduardo Cabrera,

    You can always create AOT view for 2 joined tables and then use this view as a datasource in union.

  • Community Member Profile Picture
    on at

    But you can't use the type NoExists in the view

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Ok let me give you additional details:

    A) Create a query to join 2 tables using not exists join.

    B) Create a view base on query from A.

    C) Create new query where you will union view previously created (B) with table you want.

  • Tommy Skaue Profile Picture
    Moderator on at

    Hi Eduardo

    ievgen is right. You should create multiple Levels using a combination of queries and views to best solve this. Unions can be tricky, and sometimes they even cause the client to crash while working with them. 

    So just as ievgen explains, you create two results, using the Query1 on table A as datasource on a view (View1) and Query2 on table A as datasource on a second view (View2), then you use a Third Query of type Union to combine the results of View1 and View2. Union is basically just combining two resultsets into one bigger resultset, so make sure the two views have the same columns and the columns in same order (as a good practice). 

    :-) 

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans