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
J_HinderJ_Hinder 

Many to Many Relationships

Is creating a many to many relationship between 2 sforce objects supported? If so, how to?
KimInFLAKimInFLA
Copied from the help file:
 
It is possible to create many-to-many relationships between any two objects in salesforce.com. To accomplish this you will need to create a connector custom object that has a relationship to your two primary objects. This connector will be used as an intersection table. To do this, follow the steps listed below.

1. Create the connector custom object, changing the Name field to an Auto Number format.

2. Create a lookup relationship from the connector to one of the two primary objects.

3. Create a lookup relationship from the connector to the other primary object.

4. Customize the related list on the first primary object relationship by changing the name of the related list to the name of the second primary object. To do this:

Click on:

Setup | App Setup | Build | Custom Objects.

Click on the name of the connector object. Edit both of the related lists and change the related list label to the name of the "other" object. (Step 5)

For example, If creating a many-to-many relationship between "Opportunities" and a custom object called "Production Orders": on the relationship with Opportunities change the related list name to "Production Orders". On the relationship with "Production Orders" change the related list name to "Opportunities"

Remove the auto number field and add the second primary object's name field. This is done from the page layouts:

a. Setup | App Setup | Opportunities | Page Layouts | Edit
b. Scroll down to the related lists section.
c. Highlight the "Production Orders" list.
d. Click "Edit Related List Properties".
e. Remove the autonumber field from the list of selected field.
f. Add the second primary object's name field to the list of selected objects.
g. Click "ok" and "save".


5. Repeat this for the other primary object (e.g. Production Orders).

Note to change the related list on a custom object page layout choose:

a. Setup | App Setup | Build | Custom Objects.
b. Click on the object name.
c. Scroll down to the Page Layout list and click "Edit" beside the page layout name.
d. Remove the auto number field as before and add in the name of the other primary object.
e. Click "ok" and "save".