function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Developer User 44Developer User 44 

How to create "many-to-many" relationship

Hey,

Can anyone give me an explanation on how to create "many-to-many" relationship - Between "Contacts" and "Products". So that the final result would be as follows:
1. Many contacts can have many products
2. The same product can be related to many products

Thanks
SandhyaSandhya (Salesforce Developers) 
Hi,

Refer below salesforce help article for the same.

https://help.salesforce.com/articleView?id=relationships_manytomany.htm&type=5
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 
 
Developer User 44Developer User 44
I believe this article is out of date. Since the custom  field Master-Detail Relationship does not exist any moreUser-added image
Ajay K DubediAjay K Dubedi
Hi, 

You can use a junction object to connect the two objects you want to relate to each other.
A junction object is a custom object with two master-detail relationships. Using a custom junction object, you can model a “many-to-many” relationship between two objects. For example, you create a custom object called “Bug” that relates to the standard case object such that a bug could be related to multiple cases and a case could also be related to multiple bugs.

Here is some useful links that will help in setting up your requirement:
https://help.salesforce.com/articleView?id=relationships_manytomany.htm&type=5
https://help.salesforce.com/articleView?id=relationships_manytomany.htm&type=5#JOJunctionObject

Hope it helps.
Thanks,
Ajay Dubedi.
Kate BrownKate Brown
I have created the Many-to-Many Relationship 2 objects - but then how do I create a field that basically says in Accounts - check box if account contains - the related list "Key_Accounts"