Validation rules and roll-up summaries
Key Takeaway
A roll-up summary value changes when its detail records change, so a validation rule on the master can block a save on a detail record.
A roll-up summary field shows a calculated value on a master (parent) record, such as a count or a total, based on the related detail (child) records in a master-detail relationship. A validation rule checks data before a record saves and blocks the save with an error message when its formula returns True. The two often work together, for example when a validation rule uses a roll-up summary field to limit how many detail records a master can have.
Where you can create roll-up summary fields
A roll-up summary field lives on the master object and calculates values from detail records. Because of this, the detail object must be related to the master object through a master-detail relationship.
For example, an Account field called Total Invoice Amount can sum the amounts of all related Invoice custom object records.
You can create roll-up summary fields in these places:
- Any custom object on the master side of a master-detail relationship
- Any standard object that is the master of a custom object
- Some standard relationships also support them:
- Opportunities summarizing opportunity products
- Accounts summarizing related opportunities
- Campaigns summarizing campaign member status or campaign member custom fields