You are here:
Add the Apex Actions to the Template Flows
Integrate your new Apex classes into the emergency callout process by wiring them into the template flows as Apex actions. You need to assign these Apex classes to the dispatcher profile.
Required Editions
| Available in: Lightning Experience |
| Available in: Enterprise, Performance, and Unlimited editions with Energy & Utilities - Growth, Field Service for Energy & Utilities, and Contractors for Energy & Utilities |
| User Permissions Needed | |
|---|---|
| To add Apex actions to flows: | Manage Flow |
-
Add the Apex actions to the Check Workforce Availability flow.
- From Setup, in the Quick Find box, enter Flows, and select Flows.
- Open the Check Workforce Availability flow.
- On the Yes path of the Have Service Appointment? decision, add an action element.
- Search and select Get Workforce Availability.
- Set callout ID to {!$Record.Id}.
- Set scheduling policy name to your scheduling policy, such as Emergency.
- Save and activate your flow.
-
Add the Apex actions to the Generate Emergency Callout Roster flow.
- Open the Generate Emergency Callout Roster flow.
- Create a flow input variable for the requirement ID, and configure the Add Resource modal to pass the ID to this new variable.
- On the Yes path of the Have Callout Requirement Records? decision, add an action element before the Set Success Response element.
- Search and select Generate Emergency Callout Roster.
- Set callout ID to {!callOutId}.
-
Set the callout requirement ID to your new requirement ID variable.
Important The ranking action requires the requirement ID. Without this binding, the ranking fails and returns an empty list. - Optionally, set a scheduling policy name or roster multiplier.
- Map the action's Success and Message outputs to the flow's existing isSuccess, successMessage, and errorMessage variables.
- Save and activate your flow.
-
Add the Apex actions to the Rank Emergency Call Out Resources flow.
- Open the Call Out Rank Resources flow.
- Create a flow input variable for the requirement ID, and configure the Add Resource modal to pass the ID alongside the record ID.
- On the Yes path of the Is Service Appointment Assigned? decision, add an action element before the Set Ranking Outputs element.
- Search and select Rank Emergency Callout Candidates, and give the action element the API name RankResources.
- Set callout ID to {!recordId}.
- Set the callout requirement ID to your new requirement ID variable.
- Optionally, set scheduling policy name to {!schedulingPolicyName}, or leave it blank to use the default of Emergency.
- Edit the Set Ranking Outputs element, and rewrite its assignments to carry the action's real outputs instead of the placeholder literals.
- Change rankedResourcesJson from "[]" to {!RankResources.rankedResourcesJson}.
- Change isSuccess from true to {!RankResources.isSuccess}.
- Optionally, add errorMessage set to {!RankResources.message} so that the action's soft-fail messages reach the modal.
- Save and activate your flow.
Important The ranking action requires the callout requirement ID to scope ranking to
the selected pay grade. Without this binding, the ranking fails softly and returns an empty
list. If you don't rewrite the Set Ranking Outputs assignments, the flow
keeps returning the empty list and never calls the Apex, so no ranked candidates appear in the
modal.
Did this article solve your issue?
Let us know so we can improve!
