Why can’t I create a master-detail relationship between Product and my custom object?

Trying to create a master-detail relationship between my custom object (detail) and the standard product object (master). Initially it said I couldn’t create this because I needed to make sure all child records had a parent, but there were no child records as I had literally just created the object.

So I made it a lookup relationship, but the spec requires that the custom object MUST have a product type. So after creating the lookup and then going to change the “what to do if the lookup record is deleted?” to “don’t allow deletion of the lookup record”, I get the error message: “Cannot add a lookup relationship child with cascade or restrict options to Product2 (Related field: Domain)”.

So what’s going on here because I don’t see why this can’t be done?


I can’t offer you any insight into why you cannot do this, you just can’t unfortunately, it’s a seemingly arbitrary limitation of the platform and the Product2 object. Unless someone who knows about the internals of the platform comes across this I doubt you’ll ever get a definitive answer.

In terms of working around it though, the only way to achieve this is to create your lookup as a standard non-required Lookup and then enforce that the value of this lookup cannot be blank using a validation rule.

Your validation rule will look something like this:


If the Product is deleted then this will result in the value of the field being cleared, as per the default ‘Clear the value of this field.’ behaviour, which will prevent you updating the child record until a valid lookup ID is entered.

If you want to change this behaviour you’ll have to write a before delete trigger on Product2 with your desired logic.

Source : Link , Question Author : Adam , Answer Author : Alex Tennant

Leave a Comment