Launching headless flows from the Salesforce Field Service Dispatch Console

Reed Strauss
4 min readAug 5, 2022

--

In this guide, I’ll show you a simple way to add headless flows to your dispatch console.

TL:DR install instructions below.

Visit The Field Press for more Salesforce Field Service content like this

Three steps stand between you and your headless flow on the dispatch console.

Why?

Whether you’re looking to give your dispatchers an easy way to send custom notifications to your field techs; you are looking to highlight appointments from related projects; or add some other helpful automation to your dispatch console, Salesforce flow is a great tool to help build your configurable automation.

Traditionally you would need to write both class and controller to add automation to the dispatch console. If you write your to flow accept a single record as a starting point, and let the flow perform all of the logic, you can avoid writing a controller at all. This means that you can easily add admin-configurable automation to the dispatch console, and reduce code complexity in your org.

How does this work?

The class below implements an existing Service Appointment controller. The class takes the selected service appointment, queries the Id from the record, and maps it to an object that we will pass to the flow. Then we use Flow.Interview to start a new instance of our flow, and pass in our recordId. From here all of the record querying, updating, deleting, etc. is up to the flow. That’s it. Seriously.

Example of code used to launch headless flows from the salesforce field service dispatch console.
The ‘return’ statement is what gets passed to the success message.

Note: this method of launching flows, will only launch headless flows. If you need to launch screen flows, stay tuned for my post on Launching Flows from the Field Service Dispatch Console in Lightning Runtime.

Let’s see this in action:

In the example below we are kicking off an autolaunched flow which is configured to highlight all service appointments that are related to the same parent work order. We select the service appointment that we want the flow to start on, and select the gantt action that kicks off our flow. The flow starts by reading the Id from the selected service appointment, searches for other related appointments, and then assigns a color to all of those appointments. It wraps up by passing a nice little success message.

oooh, that’s streamlined.

Try it yourself:

Pick your favorite headless service appointment flow, or write a new one. Just make sure that it starts with a recordId. Install, and update the following APEX. Create a new custom gantt action. Enjoy!

Install:

  • Navigate to the Developer Console
  • New > APEX Class
  • Name: ApexFlowLauncher
  • Paste the following code into the new class
  • Change Highlight_Gantt_Color to the name of your flow

Notes: this class is passing a text variable called recordId to the flow. Ensure that your flow has a text variable named recordId and that it is available for input and output.

Add your flow to the Field Service Dispatch Console:

  • Navigate to the Field Service Settings > Dispatcher Console UI > Custom Actions > Gantt
  • Create a New Action
  • Label the action
  • Add your newly created class
  • Save

--

--