Skip to main content

Notifications

Announcements

No record found.

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

  • ergun sahin Profile Picture
    ergun sahin 8,812 Super User 2024 Season 1 on at
    RE: Build a view by Joining 2 datasources with condition

    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).

  • Alex Nach Profile Picture
    Alex Nach 32 on at
    RE: Build a view by Joining 2 datasources with condition

    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

  • Suggested answer
    huijij Profile Picture
    huijij 19,811 on at
    RE: Build a view by Joining 2 datasources with condition

    Hi Alex,

    Do the range expressions meet your needs?

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans