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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Union Query

(0) ShareShare
ReportReport
Posted on by 1,214

Hi. I have three queries with these paths and I want to union them:

  • GeneralJournalAccountEntry -> GeneralJournalEntry -> VendTrans -> VendInvoiceJour -> VendInvoiceTrans
  • GeneralJournalAccountEntry -> GeneralJournalEntry -> CustTrans -> CustInvoiceJour -> CustInvoiceTrans
  • GeneralJournalAccountEntry -> GeneralJournalEntry -> LedgerJournalTrans

I created three separate views for each query then I plan to union them in another view.

My problem is, I want to include PurchId column from VendInvoiceJour table in the union view

but only the first path contains PurchId column. 

Since union will only work for same field and same data type, how can I include empty PurchId column in CustTrans and LedgerJournalTrans path? Simply create an empty PurchId column in the view won't work.

Thank You

*This post is locked for comments

I have the same question (0)
  • Brandon Wiese Profile Picture
    17,788 on at

    Include a similar field of the same type and length.  For branch 2, include SalesId, and for branch 3 include JournalNum.

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Hi Brandon.

    But that will include the SalesId and JournalNum values right. I don't need the SalesId and JournalNum values. I only need the PurchId then for the branch 2 and 3 the PurchId should be empty.

    Can I achieve that?

  • Verified answer
    Kanagaraj A Profile Picture
    1,254 on at

    Hi,

    please try with below solutions and should solve your problem.

    create one compute column for PurchId(same Type and stringSize) in View2 and View3 and return empty string (" ") or whatever values you want for your reference.

    Then add one 'string compute column' field and assign view method for this field.

    after you can create Union views......let me know if any issues.

    sample compute column code:

    public static server str returnBlankString()

    {

       return SysComputedColumn::returnLiteral('');

    }

    please mark it as answer if it solved problem and it may help to others to get quick solutions.

    Thanks,

     

     

     

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Hi Kanagaraj,

    exactly what I need. Thanks a bunch!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans