Skip to main content

Notifications

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

  • Community Member Profile Picture
    on at
    RE: How to display N:N relation (with a view)

    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

  • Community Member Profile Picture
    on at
    RE: How to display N:N relation (with a view)

    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.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: How to display N:N relation (with a view)

    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.

  • Suggested answer
    Wayne Walton Profile Picture
    13,728 on at
    RE: How to display N:N relation (with a view)

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

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
dkrishna Profile Picture

dkrishna 6

Featured topics

Product updates

Dynamics 365 release plans