+ Start a Discussion

Recursive data structure


I've previously posted regarding recursive data structures. But, as it now turns out, it's still causing me some headache.

What I want to model is a many-to-many relationship between the same custom object.

My scenario is this:

I have a custom object called Sales Product. Any Sales Product has a Type of either Subscription, One-Time Fee or Bundle.

Now, the issue is this. In my data model a Sales Product of Type Bundle holds a list of other Sales Products (where Type isn't Bundle). However, these Sales Products (where Type isn't Bundle) must be able to be part of many bundles which brings me back to a many-to-many relationship between Sales Product and Sales Product.

When reading through the documentation of many-to-many relationships the followint is stated: "You cannot create a many-to-many self relationship, that is, the two master-detail relationships on the junction object cannot have the same master object."

I'm guessing it's exactly that sentence that's preventing me from creating a many-to-many relationship between 2 x Sales Product.

A recursive data structure is fairly common these days. Is there any known workaround for this limitation which would help me overcome my headaches?



/Søren Nødskov Hansen

Best Answer chosen by Admin (Salesforce Developers) 

You just need to make one of the fields lookup rather than master detail on your junction object . I use this method to provide a many to many  relationship between accounts.