In a particular solution I was attempting, I created a Master-Detail relationship using a custom parent object (primary master), a custom junction object and I had wanted to use the std Leads object as the other parent. But it appears that SFDC does not allow using the Leads object as a parent in that way. I can only create lookup relationships to Leads from a custom child object.
I can’t find anything in the documentation regarding this restriction so am I missing something? If this is indeed the case, is there a workaround for that? The reason this matters is if the lead record gets deleted, I want the junction record to get deleted. And when creating the new lookup to Lead field from the custom junction object, the new relationship wizard doesn’t provide any options regarding what happens when the lookup record is deleted.
Thanks again for all the support and encouragement you provide.
Searching for a Master
Dear Searching for a Master,
As you’ve noticed, there’s a lot missing from Salesforce’s documentation pages!
You can’t have master-detail relationships on Leads because of lead conversion. Are leads deleted during conversion? Does the other object get transferred to the Account, Contact, or Opportunity? These ambiguities make Salesforce hesitant to allow master-details here, at least that’s my theory.
The good news is that standard lookup relationships are usually sufficient, unless you have special permission requirements or need to use roll-up summaries.
In your case, use the “don’t allow deletion of the lookup record that’s part of a lookup relationship” option when creating the lookup relationship. It’s not the most user-friendly way of doing things, but it’ll at least satisfy your requirements.
And if you want the best experience possible, you can always write a “delete” trigger.
Hope this helps!
Join the discussion in the comments section below! Got a question? Send it to the mailbag: email@example.com
Searching for a Master,
David was spot on. I would also add, if you want to “Simulate” a master-detail relationship, just add the lookup and then create a validation rule that enforces a value on the lookup. Then, create a delete trigger on the “parent” that also deletes all related simulated “junction” object records. Obviously this will not give you a true MD relationship but should meet your requirements.
Thanks guys, these solutions should work. So, when trying to create a MD relationship from a custom object to almost any standard object than Leads, SF allows you to select an option for how to handle the master record if the detail is deleted as David mentioned. However, no such options are provided when creating a MD to the Leads object. Try it, you’ll see what I’m talking about. I finally discovered today (after rereading the relevant documentation pages 4X) that this must be what is referred to as a cascade-delete and is not allowed by SF for a handful of std objects, Leads being one of them. Time to brush up on triggers.