Update New and Changed Records 10 Times Faster by Using Before-Save Updates in Flows

Creating or updating a record can now trigger an autolaunched flow to make additional updates to that record before it's saved to the database. Before-save updates in flows are much faster than other available record-triggered updates. For example, a before-save update in a flow is 10 times faster than an update in a record-change process that’s built in Process Builder. Replace your record-change processes with flows to minimize how often the spinner appears when users save records.

Where: This change applies to Lightning Experience and Salesforce Classic in Essentials, Professional, Enterprise, Performance, Unlimited, and Developer editions.

Who: To activate a flow that makes before-save updates, you need the View All Data permission.

Why: Perhaps you’re familiar with Process Builder and using a record-change process to make additional updates to each record that triggers the process. Such a process can set the Region custom field automatically on each new case record. Before-save updates in flows accomplish that same goal, but much more quickly because each record doesn’t get saved to the database again. Avoiding that extra save procedure means skipping another round of assignment rules, auto-response rules, workflow rules, and other customizations that take time to execute.

Perhaps you’re familiar with Apex triggers. A flow that makes before-save updates is similar to a before trigger. The previously described record-change process is similar to an after trigger. In a save procedure, before-save updates in flows are executed immediately prior to Apex before triggers.

Because of their speed, we recommend that you use before-save updates in flows to update fields on new or changed records. You can even avoid the limit for maximum CPU time on the Salesforce servers by replacing Apex code and record-change processes with before-save updates in flows. However, sometimes you need to use a record-change process or an Apex after trigger to:
  • Access field values that are set only after the record is saved, such as the Last Modified Date field or the ID of the new record.
  • Create or update related records.
  • Perform actions other than updating the record that launches the flow.

How: Create an autolaunched flow and open the Start element. For What Launches the Flow, select New or updated records—flow makes fast field updates.On the Edit Start modal, What Launches the Flow is set to New or updated records—flow makes fast field updates. Also, When to Start the Flow is set to A record is created or updated, and Object is set to Opportunity.

For a flow that makes before-save updates, the Flow Builder toolbox offers only four elements: Assignment, Decision, Get Records, and Loop.Flow Builder showing Elements tab with four items. The canvas contains a Start element labeled When Opportunity is Created or Updated, a Decision element labeled Closed Won?, and an Assignment element labeled Renew Oppty. The connector between the Decision and Assignment elements is labeled Yes.

In the flow, the $Record global variable contains the record values. Use an Assignment element to update those values, and let Salesforce handle the rest. You don’t even have to create any variables or add an Update Records element to your flow.