There is a master-detail relationship between two objects and I want to ensure that the master object should not have more than 10 child records. How can we achieve this without using a trigger ?
1 Answer
Create Roll-up summary - COUNT field on Parent object and validation rule
If you’re trying to enforce a record limit of 25 on the parent roll-up summary field, create validation rules on your child objects. When you add a child record, your validation rule on the child object can check if the count is already 25 or greater.
https://help.salesforce.com/s/articleView?id=sf.fields_about_roll_up_summary_fields.htm&type=5
from documentation - Best Practices
-
will this solution be always real-time? As mentioned here "Calculating roll-up summary field values can take up to 30 minutes, depending on the number of records affected and other factors". Commented May 29, 2022 at 12:36
-
I believe that is about sharing recalculation and owners, currency recalculation, .etc .– Pavlo MCommented May 30, 2022 at 7:34