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
Dea73Dea73 

Junction Object to itself

What possible issues can a Junction object to itself create? For example: when you have an Object called Project and you want to be able to link a Parent Project to a Child Project and vice versa.
I created the junction with lookups, i've seen where it saus that you can create the a junction with master-detail relationships.
Thanks!!
PratikPratik (Salesforce Developers) 
Hi,

Junction object is an object which helps to create many to many relationship.  As you mentioned, it can be achieved through 2 master-details relationships with 2 masters and a common detail(child) object between them.
The comon child is called as Junction object.

Is Parent Project, Child Project & Project are different objects? If not, then a simple lookup will serve the purpose. If you want to connect a Project with parent and child projects, create lookups on Project.

Also you can create a new custom object to store child Project.  You can have master- child relationship whwre your main Project will be act like parent and child project will act like child project. As it's one to many, one Project can have multiple child project.

Thanks,
Pratik 
Dea73Dea73
Hi Pratik, It’s one Object I’m working with. And I need a way to be able to apply many to many relationship. I have done this by creating a Junction Object with 2 lookups to Project in it. Bu it noticed that when being on the project object and clicking on the new button on the junction related list to create a new link (parent or child), that one of the lookup does not automatically display the name of the project I came from. It looks like a picklist and displays several values and it shows a red error message stating multiple items found. I don’t know maybe it’s because I had to embed a visual force page to display projects field and not the junction fields. Did I created the junction object in the right way? Thanks!!!
PratikPratik (Salesforce Developers) 
Hi,

As per you description above, it's not actually a junction object.  Junction object will have 2 master- details relationships with itself as a child for the 2 master object.

I did some POC on your requirement, if you want to use a single object Project and want to track Parent-child projects, Create a Lookup on Project on Project object itself.

Screenshot:

User-added image

This will look like on Project Record:

Screenshot:

User-added image


User-added image

Thanks,
Pratik
Dea73Dea73
I can’t see your screen shots! Will this give me the possibility to link many children with many parents?
PratikPratik (Salesforce Developers) 
Hi,

Both lookup and master detail are one to many relationship. To have many children to many parents ( I thought one parent and many children) you will need 3 objects with 2 master detail.  

https://help.salesforce.com/HTViewHelpDoc?id=relationships_manytomany.htm&language=en_US

Thanks,
Pratik