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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Build a view by Joining 2 datasources with condition

(0) ShareShare
ReportReport
Posted on by 32

Hello everyone.

I'm trying to join 2 data sources in D365FO to build a view, but require to have Relations to be done as a condition.
In short, I need to add additional relation to ON statement when item is discontinued to make sure no other Size is selected.

In SQL it looks like the below code.

SELECT * FROM CustomerItem i
JOIN AvailInventory a
ON
   i.itemBarCode = a.itemBarCode
   AND i.InventLocation = a.InventLocationId
   AND
   CASE
     WHEN IOVDISCONTINUED = 1 AND i.INVENTSIZEID = a.INVENTSIZEID THEN
      1
    WHEN IOVDISCONTINUED <> 1 AND i.INVENTSIZEID = a.INVENTSIZEID THEN
     1
    WHEN IOVDISCONTINUED <> 1 AND i.INVENTSIZEID <> a.INVENTSIZEID THEN
     1
    ELSE 0
  END = 1
WHERE i.ITEMBARCODE = '1234567' AND
a.ONHAND > 0 AND a.PdsDispositionCode = 'AVAILABLE'
AND i.ACCOUNTNUM = '123456'

Does anyone have an experience with building views with dynamic join or something like that?

Thank you all in advance for your input and experience. It's always appreciated.
Alex

I have the same question (0)
  • Suggested answer
    huijij Profile Picture
    19,811 on at

    Hi Alex,

    Do the range expressions meet your needs?

  • Alex Nach Profile Picture
    32 on at

    Hi Judy.

    I don't believe range will work here. I've done ranges before and it allows you to filter the result of a datasource based on one or more criteria for a specific field(s).

    What I need is a JOIN to another datasource but some times I need to use 2 relations in the JOIN and another time 3 relations depending on the field value (IOVDISCONTINUED) in the first datasource. In both cases there will be values returned back but if my item is discontinued and size in this case is locked I must get only that size from a second datasource and no other size combinations allowed.

    I hope that explains my task clearly.

    Thank you,

    Alex

  • ergun sahin Profile Picture
    8,826 Moderator on at

    It doesn't seem possible to do it in a single view (I can't think of a solution) but you can do whatever you want by combining multiple views (or queries).

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 399

#3
Adis Profile Picture

Adis 251 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans