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 CRM (Archived)

How to display N:N relation (with a view)

(0) ShareShare
ReportReport
Posted on by

Hello everyone.

I have a relation N:N between a custom entity (training day) and some contacts.
Each contact can be linked to N training days.

With the custom report wizard, I can display for each training day the trainees list. (with the Regarding option, i can see "Trainees" (contacts)).

But it is possible to display via a view this N:N relation ? It's easy to understand that behind that, i've probably an SQL table for the relation (id contact / id training day) but how can I see that with a view (entity) :

Training day 1 - Contact 1
Training day 1 - Contact 2
Training day 2 - Contact 1 ...

Thanks for your help. I hope "report" is not the only way.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Wayne Walton Profile Picture
    13,730 on at

    There is no out of the box method of showing N:N relationships in a view.  You need a report.

  • Verified answer
    Community Member Profile Picture
    on at

    You would be better off to change your design. Instead of using a native N:N relationship that uses a hidden intersect entity that you cannot get at, view or report on, create your own entity with a lookup to Training Day and to Contact.

    You can then do whatever you like with this entity, and in particular you could add more fields to hold useful information, such as the status reason of their booking (for example: tentative, confirmed, paid, attended, cancelled, no-show...), when they made the booking, special [dietary|other] requirements, feedback scores...

    Total time to build entity, custom status reasons, form and a couple of views: under 30 minutes

    Of course, if you already have lots of data using the N:N then moving this across may be easier said then done, but in the long term could be worth the effort.

  • Community Member Profile Picture
    on at

    Hi Adam and thank you for your very interesting answer.

    Thank you Wayne too.

    I've many data to migrate but I will study this possibility.

  • Community Member Profile Picture
    on at

    Hello,

    I did this way. It solve my problem:

    Suppose we have a N:N relationship between Opportunity and SystemUser

    Now we want to view all related users on opportunity view

    1. Create a field in Opportunity entity named new_usernamecombine. That holds all the combination of username

    2. When we create a N:N relationship, there's another table created in DB: new_opportunitysystemuser

    3. Create 2 triggers on this table to track the Insert and Delete event. In these triggers, update field new_usernamecombine

    create trigger UpdateSystemUserCombine_delete

    on new_opportunity_new_partnerBase

    after delete

    as

    begin

    update OpportunityBase set new_usernamecombine = (

    select pb.FirstName + ', ' from

    new_opportunity_systemuser opb

    join systemuserBase pb on pb.SystemUserId = opb.SystemUSerId

    where

    opb.OpportunityID = (select OpportunityId from deleted)

    FOR XML PATH(''))

    where

    OpportunityID = (select OpportunityId from deleted)

    end

    Hope it helps,

    Hien

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans