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)

Many-to-Many relationships from activity entity?

(0) ShareShare
ReportReport
Posted on by 1,135

Hi!

I created a custom activity entity and I would like to add a N:N relationship to Products but I can not do this. Any ideas how to add the relationship? My aim is to "show" and "link" service products with activities so that the customer can calculate what the activites costs and how many products (services) they have accomplished.

One possibility that I found out is to create the manual N:N relationship, but I suppose it requires a lot more work? Any other ideas?

*This post is locked for comments

I have the same question (0)
  • Aileen Gusni Profile Picture
    44,524 on at

    Hi JP,

    Yes, you should create Manual N:N Relationship..

    It will create an intersection table.

    Create a New Entity as intersection table.

    Create 1:N Relationship from the activity to this new entity and then 1:N to the Product.

    Then your table will have 2 lookup fields to Activity and product.

    Maybe the effort is because you create a new entity and Manual N:N you might need to give value to the new_name field and then the user need to create 1 entity record with link to the activity and product, cannot just use Native N:N that just link it each other.

    Thanks.

  • Brandon_P Profile Picture
    1,185 on at

    This is an odd design by microsoft. An activity might need to relate to another entity in many ways. the middle entity being required is odd.

    Do you have to manually populate the middle entity with all data so that the new activity can look items up in it?

    N:N relationships exist for a reason, and not having them makes no sense to me. Can anyone answer the why?

  • Suggested answer
    mscrmba Profile Picture
    on at

    You can create an N:N relationship in Dynamics CRM, but you should only do so if you don't want to be able to store details other than the actual connection between the 2 records.

    Otherwise what you create is a 1:N relationship from the first entity to a third (intersect) entity and a N:1 from the third (intersect) back to the second entity.  What that allows is the capture of e.g. a start and end date for the relationship between the two records, quantities and comments about the relationship.  Often that entity only has the two lookup fields (to entities 1 & 2) and a couple of other fields.

    *  You can look to use the OOTB Connections as a generic 'intersect' entity / way of showing these relationships and capturing whatever data you need to hold about them.  

    *  A Custom entity (acting as an intersect entity) is often a cleaner way to display this data, making reporting / views  simpler for users to understand.

    It's not difficult to configure either way.

    As for reporting you can :

    1.  Show a grid of the intersect/Connection entity on either or both of the other records.

    2. You can create views / reports from the intersect/Connection entity.  

    3. If you use a custom intersect entity then you have full flexibility to show any of the fields from either of the other records on that list view.  On it's form view you can use quick view forms to display any/all data from either or both of the related entities (1 or 2) on the same form.

    Hope that makes it a bit clearer.

  • Community Member Profile Picture
    on at

    HI

         I have used this method to create a relationship between activity entity and the contacts entity.

    My lookup allows me to select contacts to add to first activity I create, but when I try to add the same contacts to another activity I  get an error message "The record is already associated with another record" can you help ?

  • Community Member Profile Picture
    on at

    Hi

    Tthe relationship shown below works well when creating the first activity record but I get an error "The record is already associated with another record" when I try to add the same contacts to an activity.

    Is there a way to create a N:N relationship between and Activity and another Entity ?

  • mscrmba Profile Picture
    on at

    Go into Components>Entities>Intersect Entity

    Enable the Intersect entity for Activities by ticking the checkbox (note once switched on you can't switch Activities off again for that entity).

    Then create a 1:N from Contacts to the Intersect entity.

  • Community Member Profile Picture
    on at

    Thanks for your quick reply.

    I had already ticked the Activities box. The relationship is still being treated as a 1:N rather than a N:N

    The diagram below shows the relationships created.

    In my new activity "Visits" I have the option of two connections to use when I create the lookup field. one for "Contacts" the other for the "Intersect". if I use the "Contacts"  relationship it is only a 1:N. The Intersect options shows no records.

  • mscrmba Profile Picture
    on at

    I'm sorry - I misread your diagram / have given you incorrect information.

    Activities are special.  You create a 1:N between an entity and Activities by clicking the checkbox.

    If you need to create 1:N from Activities to some other entity the only way to do so is to create that relationship for each activity type.  e.g. Task, Email, Appointment, Phone Call, Letter, Fax and so on.  That means you have a number of lookup fields on the Intersect entity - one for each activity type (unless you get sophisticated with code).

  • Community Member Profile Picture
    on at

    I must be missing something.

    I have created a 1:N from my individual activity "Visits" to the intersect entity. plus a 1:N from "Contacts" to the intersect entity. This allows me to add multi contacts to my "Visits" activity only once. If I try to create a second activity record I get the error message "Record already related"   I don't seem to be able to connect  my "Visits" activity to the contacts entity with a N:N relationship.

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