The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Choosing between roll-up summaries and Formula Fields in Salesforce (opens in a new tab)

You will know when a value needs a roll-up summary, a Formula Field, or a Flow or Apex alternative, based on relationship type and the shape of the calculation.

Why read this

The piece ends with a short decision checklist.

Roll-up summary

  • Aggregates child records
  • Master-detail only
  • Recalculates on child change
  • No lookup relationships

Formula Field

  • Uses one record's fields
  • Lookup or master-detail
  • Recalculates on each view
  • Never stale at read time
Roll-up summaries and Formula Fields differ in what they calculate and where they work

The article distinguishes roll-up summary fields from Formula Fields. A roll-up summary sits on a parent record and aggregates its child records through count, sum, min or max. It works only on master-detail relationships and recalculates when a child changes. A Formula Field calculates from a single record’s own fields and related parent fields, recalculating each time the record is viewed, and works on both lookup and master-detail relationships.

Roll-ups suit jobs such as counting open cases on an account or summing opportunity amounts, and they stay accurate without extra queries or flows. Their limits are basic filter criteria, no more than one relationship level, and no support for lookup relationships. Formulas suit record-level logic such as age fields, name concatenation or flags driven by a few fields. The trap is formulas that reach across many objects, which become hard to read and can slow List Views and reports on large data volumes.

The article closes with a checklist: many children into one parent number points to a roll-up, a value derived from the record itself points to a formula, a lookup relationship needs Flow or similar tooling, and complex filtering or cross-object aggregation needs Flow or Apex.

Read the original at dev.to (opens in a new tab)

Worth reading?

Six practical Validation Rule patterns to improve data quality in Salesforce (opens in a new tab)

Readers will learn six ready-to-use Validation Rule formulas that prevent common data entry mistakes, along with best practices for writing clear field-level error messages.

  1. User enters or edits a record
  2. Validation Rule formula is evaluated
  3. Bad data is blocked with a clear error
  4. Error appears at the field level
How a Validation Rule stops bad data before it is saved, using the article's approach

The article outlines six Validation Rule patterns designed to catch frequent user errors without requiring Apex or Flow. These include preventing Closed Won Opportunities from missing amounts or close dates, blocking Cases with backdated open dates beyond a seven day window, and ensuring close dates never precede creation dates.

Additional patterns address picklist state management by stopping records from reverting to New once closed, unless a custom bypass permission is granted. The piece also requires a reason field when priority changes to High status, and locks amount fields during approval reviews to prevent revenue leakage.

Beyond the formulas, the author emphasizes error message hygiene. Rules should be named clearly, descriptions filled out for audits, and errors placed at the field level rather than the page header. Messages must instruct users on the correct action instead of simply stating an invalid value. The author notes that while Validation Rules stop immediate data issues, field level required attributes or Flow notifications may be better alternatives for certain workflows.

Read the original at dev.to (opens in a new tab)

Worth reading?