---
schema_version: "1"
id: a39b50c4f3890f9a93829be06166daaa3203808eb2fe30d6f06c53d5b72e0858
title: Add the Apex Actions to the Template Flows
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/energy_add_the_apex_actions_to_the_template_flows.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.energy_add_the_apex_actions_to_the_template_flows.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: d3b37fd9dc192ca20c2303da910ca71d8df0aa28af99af7b26835c707db77584
description: 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.
products:
  - Energy and Utilities
release: "264"
---
# 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

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col style="width:100%"></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Performance</strong>, and <strong>Unlimited</strong> editions with Energy &amp; Utilities - Growth, Field Service for Energy &amp; Utilities, and Contractors for Energy &amp; Utilities</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:left;vertical-align:top;" id="d48128e72">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d48128e72 ">To add Apex actions to flows:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d48128e72 ">Manage Flow</td>

          </tr>
        </tbody>
      </table>

1. Add the Apex actions to the Check Workforce Availability flow.
    1. From Setup, in the Quick Find box, enter Flows, and select **Flows**.
    2. Open the **Check Workforce Availability** flow.
    3. On the **Yes** path of the **Have Service Appointment?** decision, add an action element.
    4. Search and select **Get Workforce Availability**.
    5. Set callout ID to {!$Record.Id}.
    6. Set scheduling policy name to your scheduling policy, such as Emergency.
    7. Save and activate your flow.
2. Add the Apex actions to the Generate Emergency Callout Roster flow.
    1. Open the **Generate Emergency Callout Roster** flow.
    2. Create a flow input variable for the requirement ID, and configure the **Add Resource** modal to pass the ID to this new variable.
    3. On the **Yes** path of the **Have Callout Requirement Records?** decision, add an action element before the **Set Success Response** element.
    4. Search and select **Generate Emergency Callout Roster**.
    5. Set callout ID to {!callOutId}.
    6. Set the callout requirement ID to your new requirement ID variable.
        
        ![Important](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-energy_utilities-264-0-0-production-enus/520849e5-9b41-4bae-b97b-d269cc2fce83/images/icon_important.png)
        
        Important The ranking action requires the requirement ID. Without this binding, the ranking fails and returns an empty list.
    7. Optionally, set a scheduling policy name or roster multiplier.
    8. Map the action's **Success** and **Message** outputs to the flow's existing isSuccess, successMessage, and errorMessage variables.
    9. Save and activate your flow.
3. Add the Apex actions to the Rank Emergency Call Out Resources flow.
    1. Open the **Call Out Rank Resources** flow.
    2. Create a flow input variable for the requirement ID, and configure the **Add Resource** modal to pass the ID alongside the record ID.
    3. On the **Yes** path of the **Is Service Appointment** Assigned? decision, add an action element before the **Set Ranking Outputs** element.
    4. Search and select **Rank Emergency Callout Candidates**, and give the action element the API name RankResources.
    5. Set callout ID to {!recordId}.
    6. Set the callout requirement ID to your new requirement ID variable.
    7. Optionally, set scheduling policy name to {!schedulingPolicyName}, or leave it blank to use the default of **Emergency**.
    8. Edit the **Set Ranking Outputs** element, and rewrite its assignments to carry the action's real outputs instead of the placeholder literals.
    9. Change rankedResourcesJson from "\[\]" to {!RankResources.rankedResourcesJson}.
    10. Change isSuccess from true to {!RankResources.isSuccess}.
    11. Optionally, add errorMessage set to {!RankResources.message} so that the action's soft-fail messages reach the modal.
    12. Save and activate your flow.

![Important](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-energy_utilities-264-0-0-production-enus/520849e5-9b41-4bae-b97b-d269cc2fce83/images/icon_important.png)

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.