Launch Screen Flows Automatically When a Record Changes with ‘Detect and Launch’ Page Component

This Post was most recently updated on 9/10/22
Credits: Derek Camp from GearsCRM : we can now pass the recordId to the Flow

Credits: Andy Haas for adding conditionality.


Suppose you have a screen flow that you want to automatically launch whenever you’re on a record page and the record changes. Most likely, this will be because you just edited the record. As an example, suppose you want to make it so that every time a Case is edited and its priority changes, a screen flow runs that asks the user to provide some extra reasons if the priority has been raised to ‘High’.

This new DetectAndLaunch component makes this easier. It’s designed to sit invisibly on a page and listen for an event that gets fired by Salesforce when a record changes. Simply provide Detect and Launch with the name of the flow you’d like to run. As design, it will load the flow into a subtab if the app is in console mode, and a separate browser tab or page if the app is not in console mode.

Features

  1. Launching a screen flow when a record is edited can now be further configured to make the launch dependent on a particular field value change. Example: you need an agent to fill in specific details when they close a case or your sales reps need to send a quote to the customer you can launch a flow after a specific field has changed and, for example, is equal to true. 
  2. You can now trigger screen flows to run on the Load of a record page, and not just on an Edit or a delete

Limitations

This component uses the force:recordData component and that component doesn’t support all Salesforce standard objects. For example, the Event and Task objects are not supported. For a list of supported objects, see the User Interface API Developer Guide.

This demo was produced for V2.0 and shows Conditional Launch Based on a Field Edit:

Triggering a screen flow when a record page loads

Perform this with the new input field ‘Flow Name (when the record is loaded)’. You can use this to launch the flow when the record is opened. Note that if you are using Launch Mode = Modal, you will need to build a close function within the flow, as the modal doesn’t have a close function, yet.

Conditional Screen Flow Launch Based on a field edit

Let’s say you have a case record that you want to launch a flow when the case is closed to get the user to enter the amount of time that they spent on the case. To configure this within Detect and Launch, enter the flow name you want in ‘Flow Name ( when the record is edited )’, set Change Field to ‘Status’, and set Change Value to ‘Closed’. 

Want to check multiple fields and launch different flows based on them? Or run different flows depending on the value of the field? Add multiple Detect and Launches with different criteria to launch different flows.

Example Configuration

Inputs

Flow Name (when Record is edited)editFlowNameThe apiName of a flow you want to launch when the record is updated. Will work if this component is added to a record home page.
Flow Name (when Record is deleted)deleteFlowNameThe apiName of a flow you want to launch when the record is deleted. Will work if this component is added to a record home page.
Launch ModelaunchModeCan be ‘Modal’ or ‘Modeless’. Modeless is the default. Modal only works on an edit and not on a delete.
Change Field (What Field To Watch For)Change FieldIs used to signify what field you want to watch when a record has been edited. Used only with editFlowName
Change Value (What value are we looking for)Change ValueUsed to be the comparison value when the record has been edited. 
Flow Name (When Record is Loaded)Flow Name (when the record is Loaded)Use this to launch the flow when the record is opened.

Install

Version 2.0 Production Sandbox 9-10-22 Conditional Field-based Launching

Source

source

Old Versions

Version 1.2.1 Unlocked – 7/9/21 – Derek Camp, GearsCRM
Passes the recordId value to the Flow

Version 1.2 Unlocked 12/26/20
Changes referenced field name from Subject to Id

Version 1.1 Unlocked 9-6-20

Version 1.0.0 Unlocked 8-29-20