---
schema_version: "1"
id: 18d7719abbab2528fcc128de5395ddf006fe9a7766b4d9ea0fb4e53fef82bef5
title: "Use Case: Use a Switch Element to Show Screens Based on Conditional Logic"
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/service/264-0-0/messaging_dynamic_whatsapp_flow_switch_element.md
canonical_url: https://help.salesforce.com/s/articleView?id=service.messaging_dynamic_whatsapp_flow_switch_element.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 81682195d56cf9c2d7f6a91347a678c434ff1ce90b649b1002ff8bc70a3fa952
description: Use the Switch screen element to dynamically show or hide content. It compares a single field value against one or more specified values, and then displays the content associated with the first value that is an exact match. If no match is found, it returns the preconfigured default value. Unlike the If element, Switch is limited to performing an exact match comparison on a single field and doesn’t support complex logical operators like AND or OR.
products:
  - Service Cloud
  - Digital Engagement
release: "264"
---
# Use Case: Use a Switch Element to Show Screens Based on Conditional Logic

Use the Switch screen element to dynamically show or hide content. It compares a single field value against one or more specified values, and then displays the content associated with the first value that is an exact match. If no match is found, it returns the preconfigured default value. Unlike the If element, Switch is limited to performing an exact match comparison on a single field and doesn’t support complex logical operators like AND or OR.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <tbody>
          <tr class="">
            <td class="slds-cell-wrap" colspan="2" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=service.messaging_editions.htm&amp;language=en_US" target="_blank">View supported editions.</a></td>

          </tr>
          <tr class="">
            <td class="slds-cell-wrap" style="vertical-align:top;">
              <a name="messaging_dynamic_whatsapp_flow_switch_element__image_cgj_vgf_5cc"><!-- --></a><span style="vertical-align:text-bottom;display:inline-block;"><img style="margin-bottom:0;" id="messaging_dynamic_whatsapp_flow_switch_element__image_cgj_vgf_5cc" src="https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/resources-global/_corporate/images/checkmark.png" alt="Checkmark"></span>
              <strong>This article applies to:</strong>
            </td>

            <td class="slds-cell-wrap" style="vertical-align:top;">Enhanced WhatsApp channels, Unified WhatsApp</td>

          </tr>
          <tr class="">
            <td class="slds-cell-wrap" style="vertical-align:top;">
              <span style="vertical-align:text-bottom;display:inline-block;"><img style="margin-bottom:0;" src="https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/resources-global/_corporate/images/crossmark.png" alt="X icon"></span>
              <strong>This article doesn’t apply to:</strong>
            </td>

            <td class="slds-cell-wrap" style="vertical-align:top;">Enhanced In-App Chat, Enhanced Web Chat, Standard and Enhanced Facebook
              Messenger, Standard and Enhanced SMS, Enhanced Apple Messages for Business, Enhanced
              LINE, and Bring Your Own Channel</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:center;vertical-align:top;" id="d161084e93">User Permissions
              Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d161084e93 ">To create messaging components: </td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d161084e93 ">
              <p>Customize Application AND View Setup and Configuration</p>
              <p>OR</p>
              <p style="margin-bottom:0;">System Administrator</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d161084e93 ">To send and receive messages in Messaging: </td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d161084e93 ">Messaging Agent</td>

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

To illustrate how to use Switch, consider this example. You are the admin for Healthy Pets, a veterinary hospital. Your job is to build a WhatsApp Flow, where the initial screen asks the customer for their animal type, and then sends them to a screen to provide details about the animal. To share specific details about each animal type, create a different screen for each type. For example, if the customer selects Cat, the Next button takes them to the Cat screen. After providing animal-specific information, the customer is then sent to the final screen, where they confirm their account information.

This example assumes that you already created the WhatsApp Flow with these screens.

![The WhatsApp flow contains 5 screens with content.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/messaging/messaging_form_component_whatsapp_flow_screens_list.png)

1. In the Component Formats section of the Form messaging component, select **Flow**.
2. In the Screens section, expand the Animal Type screen and add a dropdown screen element that shows: Cat, Dog, Bird, and Other Animal.
    
    ![There are different options for each animal type, including cat and dog.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/messaging/messaging_form_component_whatsapp_flow_animaltype_dropdown.png)
3. To preview the Animal Type screen, in Component Properties in the right sidebar, select and expand the screen node.
    
    ![The previous shows the results of the dropdown selection configuration.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/messaging/messaging_form_component_whatsapp_flow_screen_animal_type.png)
4. To advance the user to the next screen based on their animal type selection in the Animal Type screen, add a Switch element.
5. In the Component Properties of the Animal Type screen, click **Add Content**, select **Switch** under Conditional Logic, and click **Done**.
6. To configure the Switch element, expand the Switch node and click **Edit**.
    
    ![The screen configuration shows different screen elements, including the Switch element.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/messaging/messaging_form_component_whatsapp_flow_switch_element.png)
7. In Select Field, select the field that the customer uses to choose their animal type.
8. Add a separate case for each animal type that can be selected.
    
    For the Literal Value field, enter the ID, not the display label, of every selection that you defined in the Dropdown Selection screen element in the Animal Type screen.
    
    ![The conditional logic defines a separate case for each animal type.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/messaging/messaging_form_component_whatsapp_flow_switch_cases.png)
9. Click **Next**.
10. For each case, select the content to show when that condition is true.
    
    For example, add a Next button in the footer that takes the customer to the Cat page if they selected Cat as the animal type.
    
    1. To add a button that advances to the animal type screen, click **Add Content**, expand Other Content Types, and select **Footer**.
    2. Enter the footer details, including entering “Next” as the button label and selecting the animal type screen in the Next Screen field.
        
        ![The configuration shows a Next button that navigates to the Cat page if cat is selected as the animal type.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/messaging/messaging_form_component_whatsapp_flow_switch_cat_case.png)
    3. Click **Next**.
        
        The Define Switch Logic and Conditional Content modal walks you through every case so that you can configure what content to show. For all of them, add the Next button that takes them to the animal type’s page.
    4. When you’re done, click **Save**.
        
        In the Component Properties, the Switch node shows the cases and the resulting content for each case.
        
        ![The Component Properties shows the results when different animal types are selected.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/messaging/messaging_form_component_whatsapp_flow_switch_summary.png)