There are many use cases where there is need to set one of the child record as primary and when another child record is updated as primary it should throw up an error saying that primary record already exists (similar to contact roles function). Many of the developers would suggest an apex trigger solution But this can be achieved through configuration alone.
Its a simple 2 step process.
Its a simple 2 step process.
- Create a Roll up summary field on the parent object. It would roll up the count of the child records which have the primary checkbox set to true.
- Create a validation rule on this field if the number becomes more than 1 validation error will be thrown.