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
UmapenUmapen 

master-detail for same object

I have to create a related list to the contacts.

 Contactid  Related-contacts

       5             7

       5             6

       1             5

       1             7

       7             2

 

should I create a new object with master detail? what will the unique id? Or should I create a junction table? Each contact will have related-contacts listed. Contact owner will have ability to modify related list. 

1. Need to maintain a set of related contact id for every given contact.

2. User has ability to delete add to update related contacts

3.  There is no hierarchy here.

 

How can I do this any suggestions?

Best Answer chosen by Admin (Salesforce Developers) 
werewolfwerewolf
You should either create a junction object or make a lookup relationship from Contact to Contact.

All Answers

werewolfwerewolf
You should either create a junction object or make a lookup relationship from Contact to Contact.
This was selected as the best answer
UmapenUmapen

thanks for the quick response. I create an object RelatedContacts with  2 fields datatype as Lookup(Contact).

 

How do I write SOQL that finds all the contacts related to a given contact.

 

Documentation states that -

"You cannot create a many-to-many self relationship, that is the two mater-detail relationships on the juntion object cannot have the same master object"

Does my scenario fall into this category?

 

Thanks

 

werewolfwerewolf
Hmm, I never noticed that in the docs before.  So is that your goal -- to relate many contacts to many contacts?  Or are you relating many contacts to one contact?
UmapenUmapen

For every contact I will have related contacts

 example for contact ID 5  related contacts are 7,8,3

             for contact ID 7 related contact are 5,6, 9

 

I think this is many to many isn't it?