Submit For Review

Triggering Flows

Title Changes:

Triggering FlowsTriggering Flows

Content Changes:

  Added: There are two ways to trigger flows based on a record change. You can trigger the flow to run just before the record is changed or just after the record has been changed.
Deleted: <p>There are two ways to trigger flows based on a record change. You can trigger the flow to run just before the record is changed or just after the record has been changed.</p><p>Currently, if you want to trigger after the record has been changed, you create a Process Builder process and use it to launch your Flow.  As of Summer 2020, you have an ability to trigger a flow upon record update without process builder.  Theoretically, this could be the beginning of replacing Process Builder, but it still has some work to be done (changed values and the Isnew() function are two big highlights!). See the <a href="https://releasenotes.docs.salesforce.com/en-us/summer20/release-notes/rn_forcecom_flow_fbuilder_after-save_trigger.htm">documentation here</a>, and also a great blog post by MVP Jen Lee <a href="https://jenwlee.com/2020/02/07/run-flows-on-record-changes-before-save-updates/">Here</a>.</p><p>If you want to trigger before the record has been changed, you can do so directly from Flow, as of Spring ’20. The functionality <a href="https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_forcecom_flow_fbuilder_before_save_updates.htm?edition=&amp;impact=">documentation is here. </a></p><p><strong>Considerations when using Before-Save Triggers</strong></p><p>Normally, if you want to update a record, you use the Update Records element. But with a Flow that’s triggered by a Before-Save Trigger, the update will happen automatically and you should not try to add an Update Record element to it.</p><p>A before-save flow also runs up to 10 times faster than other record update measures (See the Salesforce documentation <a href="https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_forcecom_flow_fbuilder_before_save_updates.htm">here</a>.</p><h2>Order of Execution</h2><p>Before save triggers will fire before the PB ones (since PB is after save), so customers should generally avoid editing the same fields in both before-save and after-save triggers, as they might get weird results. Before-save will obviously always get applied first, but if a process fires off another save the before-save trigger could get executed again (and the process will again), so if they’re not careful they could cause nondeterministic loops (up until the PB recursion limit).</p><h4><span style="text-decoration: underline">Resources</span></h4><ul><li><a href="https://github.com/aidan-harding/flow-recursion">Before-Save Flows and Accidental Recursion</a></li><li><a href="https://jenwlee.com/2020/09/28/winter-21-introducing-the-before-delete-record-triggered-flow/">Jen Lee on Before Delete Flows</a></li><li><a href="https://tddprojects.atlassian.net/wiki/spaces/SF/pages/789250121/Before-Save+Flows">Jodie Miners on Before-Save Flows</a></li><li><a href="http://bobbuzzard.blogspot.com/…/spring-20-before-save-flows-and-apex">Spring 20 Before-Save Flows and Apex Triggers (Bob Buzzard)</a></li><li><a href="https://www.linkedin.com/pulse/using-before-save-flow-feature-update-region-field-gidi-abramovich/">Using Before-Save Flow and Custom Metadata Type to Update a Region​ Field</a> (Gidi Abramovich)</li><li><a href="https://www.linkedin.com/pulse/using-before-save-flow-prevent-record-creationupdate-based-gidi/">Using Before-Save Flow to Prevent a Record Creation/Update based on its Sibling Records’​ data</a> (Gidi Abramovich)</li></ul><p>—————</p><ul><li><a href="https://unofficialsf.com/the-salesforce-automation-and-decisioning-wiki/about-this-wiki/">About this wiki</a></li></ul> Added: Currently, if you want to trigger after the record has been changed, you create a Process Builder process and use it to launch your Flow.  As of Summer 2020, you have an ability to trigger a flow upon record update without process builder.  Theoretically, this could be the beginning of replacing Process Builder, but it still has some work to be done (changed values and the Isnew() function are two big highlights!). See the <a href="https://releasenotes.docs.salesforce.com/en-us/summer20/release-notes/rn_forcecom_flow_fbuilder_after-save_trigger.htm">documentation here</a>, and also a great blog post by MVP Jen Lee <a href="https://jenwlee.com/2020/02/07/run-flows-on-record-changes-before-save-updates/">Here</a>.
  Added: If you want to trigger before the record has been changed, you can do so directly from Flow, as of Spring ’20. The functionality <a href="https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_forcecom_flow_fbuilder_before_save_updates.htm?edition=&amp;impact=">documentation is here. </a>
  Added: <strong>Considerations when using Before-Save Triggers</strong>
  Added: Normally, if you want to update a record, you use the Update Records element. But with a Flow that’s triggered by a Before-Save Trigger, the update will happen automatically and you should not try to add an Update Record element to it.
  Added: A before-save flow also runs up to 10 times faster than other record update measures (See the Salesforce documentation <a href="https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_forcecom_flow_fbuilder_before_save_updates.htm">here</a>.
  Added: <h2>Order of Execution</h2>
  Added: Before save triggers will fire before the PB ones (since PB is after save), so customers should generally avoid editing the same fields in both before-save and after-save triggers, as they might get weird results. Before-save will obviously always get applied first, but if a process fires off another save the before-save trigger could get executed again (and the process will again), so if they’re not careful they could cause nondeterministic loops (up until the PB recursion limit).
  Added: <h4><span style="text-decoration: underline;">Resources</span></h4>
  Added: <ul>
  Added: <li><a href="https://github.com/aidan-harding/flow-recursion">Before-Save Flows and Accidental Recursion</a></li>
  Added: <li><a href="https://jenwlee.com/2020/09/28/winter-21-introducing-the-before-delete-record-triggered-flow/">Jen Lee on Before Delete Flows</a></li>
  Added: <li><a href="https://tddprojects.atlassian.net/wiki/spaces/SF/pages/789250121/Before-Save+Flows">Jodie Miners on Before-Save Flows</a></li>
  Added: <li><a href="http://bobbuzzard.blogspot.com/…/spring-20-before-save-flows-and-apex">Spring 20 Before-Save Flows and Apex Triggers (Bob Buzzard)</a></li>
  Added: <li><a href="https://www.linkedin.com/pulse/using-before-save-flow-feature-update-region-field-gidi-abramovich/">Using Before-Save Flow and Custom Metadata Type to Update a Region​ Field</a> (Gidi Abramovich)</li>
  Added: <li><a href="https://www.linkedin.com/pulse/using-before-save-flow-prevent-record-creationupdate-based-gidi/">Using Before-Save Flow to Prevent a Record Creation/Update based on its Sibling Records’​ data</a> (Gidi Abramovich)</li>
  Added: </ul>
  Added: —————
  Added: <ul>
  Added: <li><a href="https://unofficialsf.com/the-salesforce-automation-and-decisioning-wiki/about-this-wiki/">About this wiki</a></li>
  Added: </ul>