- 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.
U are good to go now. When the child record is updated to primary rollup would happen. But when there is a primary record rollup will try to become 2 triggering the validation error thus preventing it from saving the record. But if the relationship between child and parent is lookup or u want user to be pointed to the primary record in the error message listen to developers 🙂