[SalesForce] Master-Detail Relationship on Custom Object from Managed Package
Is it possible to add Master-Detail Relationship on Managed Custom Object? currently I am getting below error
Best Answer
You can, however create a trigger on a custom object from a managed package. Thus you can essentially fake a m/d
Given a custom object of bar__c in the managed Package namespace foo__ you would create a trigger on
trigger foo__bar__c (after insert, after update, before delete) {
//trigger logic here. Trigger.new will contain the managed custom objects that
// caused the trigger to fire.
}
A trigger that is fired after insert, after update and before delete has the ability to establish or delete any needed relationships with other objects.
You'll just need to find or create the related records, and populate a lookup field on them.
As a best practice, don't exceed 10,000 child records for a master-detail relationship.
Refers to record relationships, thus it is refering to a parent record with the number of related child records not exceeding 10,000. Thus it means 'per Master' record.
Your only option is changing the Master-Detail relationship to a lookup. In a Master-Detail relationships, according to the documentation:
The detail record inherits the sharing and security settings of its master record.
To retain the same features of a master detail you'll want to mark the lookup as required and and set it up to delete the child record when the parent is deleted.
Best Answer
You can, however create a trigger on a custom object from a managed package. Thus you can essentially fake a m/d
Given a custom object of bar__c in the managed Package namespace foo__ you would create a trigger on
A trigger that is fired after insert, after update and before delete has the ability to establish or delete any needed relationships with other objects.
You'll just need to find or create the related records, and populate a lookup field on them.