How do we restrict the number of children to 1 in a lookup relationship?
[SalesForce] Restrict the number of children in lookup relationship
Related Topic
- [SalesForce] Can Many to Many relationship be achieved using lookup relationship
- [SalesForce] Lookup Filter with related fields that are more than one relationship away from the lookup object
- [SalesForce] Maximum number of children allowed in a parent-to-child lookup relationship
- [SalesForce] The number of Lookup relationship that an object can have are as in today
Best Answer
You would first need a way to know the count of children object your parent object has. If it were a master-detail relationship, you could use a rollup summary field for this.
You could change your lookup to a master detail, but if you don;t want to do that and keep it as a rollup, you have a few options.
Once you have one of these created, then you will have a field on the parent that gives you the count of children. Then you just need to write a validation rule on the parent that ensures this count field in not greater than 1.