---
schema_version: "1"
id: e59134b1c8d3f147e55c3273dcf212e3540c986a337a5858f728af35c1a71e53
title: Email Contacts that a User Selects on a Screen Example
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/automate_flow_build_example_screen_action.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.automate_flow_build_example_screen_action.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: f1b9dc14da89059ae0e477a9819b7a1b4537349fd9255612d75b50ed0c6028aa
description: This example uses an automatically triggered screen action to let users select an account and instantly view or select related contacts—all within a single screen. Then, it sends the selected contacts an email.
products:
  - Flow Builder
  - Salesforce Platform
release: "264"
---
# Email Contacts that a User Selects on a Screen Example

This example uses an automatically triggered screen action to let users select an account and instantly view or select related contacts—all within a single screen. Then, it sends the selected contacts an email.

#### See Also

- [Action Button Screen Input Component](https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements_screencmp_action_button.htm&release=264.0.0&type=5 "Use the Action Button component so the running user can trigger a screen action with the click of a button on a screen. The screen action runs an active autolaunched flow, and the results of the autolaunched flow can be shown on the same screen as the button. Using this component means that you need fewer screens so users can complete screen flows more quickly.")
- [Data Safety When Running Screen and Autolaunched Flows in System Context](https://help.salesforce.com/s/articleView?id=platform.flow_distribute_context_data_safety_system_context.htm&release=264.0.0&type=5 "Screen flows and autolaunched flows without triggers can expose more data than intended. This potential issue primarily affects Experience Cloud sites accessed by external users. Configure proper user permissions for field-level and record-level security instead of running flows in system context. When system context is necessary, use only the minimum fields and records required.")

## Create the Associated Autolaunched Flow to Get Records

Create the autolaunched flow that gets the contact records for the selected account.

1. From the Automation app, click **New**.
2. Click **Autolaunched**.
3. Click **Autolaunched Flow (No Trigger)**.
4. Click **Create**.
    
    The new autolaunched flow opens in Flow Builder
5. Create a text input variable to store the account ID that's passed into the flow.
    1. Open Toolbox.
    2. Click **New Resource**.
    3. Select **Variable**.
    4. For API Name, enter inputAccountId.
    5. For Data Type, select **Text**.
    6. For Availability Outside the Flow, select **Available for input**.
    7. Click **Done**.
        
        ![New text resource that's available for input](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/automate_flow_build_new_input_resource.png)
6. Create a record collection output variable to store the contact records to send back to the screen flow.
    1. Open Toolbox.
    2. Click **New Resource**.
    3. Select **Variable**.
    4. For API Name, enter outputContacts.
    5. For Data Type, select **Record**.
    6. Select **Allow multiple values (collection)**.
    7. For Object, select **Contact**.
    8. For Availability Outside the Flow, select **Available for output**.
    9. Click **Done**.
        
        ![New collection resource that's available for output](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/automate_flow_build_new_output_resource.png)
7. Add a Get Records element.
    
    1. Click the plus icon and select **Get Records**.
    2. For Label enter Get Contacts.
    3. For API Name, enter Get\_Contacts.
    4. For Object, select **Contact**.
    5. In the Filter Contact Records section, for Field, click**AccountId**, for Operator, click **Equals**, and for Value, click **inputAccountId**.
    6. For How Many Records to Store, select **Only the first record**.
    7. For How to Store Record Data, select **Choose fields and let Salesforce do the rest**, and then add the **First Name,** **Last Name**, and **Email** fields.
        
        We're storing only these fields because they're the ones that we want shown in the Data Table component. Only storing the fields that you need reduces loading times for your running user and makes your data safer. For more information about data safety in screen flows, see [Data Safety When Running Screen and Autolaunched Flows in System Context](https://help.salesforce.com/s/articleView?id=platform.flow_distribute_context_data_safety_system_context.htm&type=5&language=en_US).
    
    ![A Get Records element that's retrieving contact records with an AccountId that equals inputAccountId](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/automate_screen_flows_screen_actions_create_autolaunched_flow.png)
8. Add an Assignment element.
    
    1. Click the plus icon and select **Assignment**.
    2. For Label, enter Set Output Variable.
    3. For API Name, enter Set\_Output\_Variable.
    4. In the Set Variable Values section, for Variable, click **outputContacts**, for Operator, click **Equals**, and for Value, click **Contacts from Get Contacts**.
    
    ![Assignment element that's assigning the contacts from the Get Records element to the output variable](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/automate_screen_flows_screen_actions_create_autolaunched_flow_2.png)
9. Save the flow.
10. For Label enter Get Contacts for Account, and for API Name, enter Get\_Contacts\_for\_Account.
11. Test and activate your flow.

## Create an Input for the Screen Action to Send to the Autolaunched Flow

Create a screen flow that has a screen with a Lookup component on it to allow the running user to find and select an Account.

1. From the Automation app, click **New**.
2. Click **Screen**.
3. Click **Screen Flow**.
4. Click **Create**.
    
    The new screen flow opens in Flow Builder
5. Add a Screen element.
    
    1. Click the plus icon and then select **Screen**
    2. For Label, enter Select Account and Contacts and let the API name autofill.
    3. In the Components menu, click **Lookup**.
    4. For API Name, enter Set Output Variable.
    5. For API name, enter SelectAccount.
    6. For Field API Name enter AccountId.
        
        AccountId is the API name of the Account Name lookup field on the Contact object that we want to copy functionality from
    7. For Label, enter Select Account.
    8. For Object API Name, enter Contact.
        
        Contact is the API name of the object that has the lookup field that we want to copy functionality from.
    
    ![Lookup screen component that searches for an account](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/automate_screen_flows_screen_actions_lookup_component.png)

## Set Up the Screen Action

Set up the screen action to get contacts for the selected account. You decide you want to trigger the screen action automatically as soon as the running user selects an account.

1. Click the screen element header to open Screen Properties.
2. Click **Configure Screen Actions**
3. For Flow, select **Get Contacts for Account**
4. For Label, enter Get Contacts for Account.
5. For API Name, enter Get\_Contacts\_for\_Account\_Action.
6. In the Set Action Run Settings section, for inputAccountId, click the switch to include the input. Then select the account that was selected in the Lookup component. Select the **SelectAccount** screen component, and then click **recordId**.
    
    ![Set Action Run Settings section with input selected](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/automate_screen_flows_screen_action_inputs.png)

## Use the Autolaunched Flow's Data in the Screen Flow

Use the contacts retrieved from the autolaunched flow to populate a Data Table component. Show the first name, last name, and email address of the contacts in the Data Table component.

1. From the Components menu, click **Data Table**.
2. For API Name, enter ContactsDataTable.
3. For Label, enter Select Contacts for Account.
4. For Source Collection, click **Get\_Contacts\_for\_Account\_Action**, then click **Results**, and then click **outputContacts**.
5. For Configure Columns, add the **First Name,** **Last Name**, and **Email** fields.
    
    ![A Data Table component that uses the output of the screen action for the source collection](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_screen_action_results_in_data_table.png)
    
    The running user can select an account and then select related contacts all on the same screen.
6. Save your work.

## Use the Collected Data Later in the Flow

Take the contacts selected in the Data Table component and send them an email using the Send Email action.

![Important](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/images/icon_important.png)

Important To send email from Salesforce, the Send Email action in Salesforce Flow requires domain-level and user-level email verification. Email delivery fails if either the user's email address or the email-sending domain is unverified. See [Requirements to Send Email from Salesforce](https://help.salesforce.com/s/articleView?id=xcloud.security_email_verification_requirements.htm&language=en_US&type=5).

1. Create a collection variable.
    
    This variable holds the email addresses of the contacts that you want to email.
    
    1. In the Toolbox, click **New Resource** and then select **Variable**.
    2. For API Name, enter EmailAddresses and for Data Type, select **Text**.
    3. Select **Allow multiple values (collection)** and save your work.
2. Add a Loop element.
    
    This step tells the flow to go through the selected contacts
    
    1. On the canvas, click the plus icon and then select **Loop**
    2. For Label, enter Iterate Over Selected Contacts and let the API name autofill.
    3. For the Collection Variable, select **Select Account** | **ContactsDataTable** | **Selected Rows**.
        
        This step tells the flow that we are going to go through the list of selected contacts and do something with them.
3. Add an Assignment element.
    
    This step takes the email address of each selected contact as it goes through the loop and adds it to the collection variable we created.
    
    1. After For Each, click the plus icon and then select **Assignment**
    2. For Label, enter Add Email to Email Addresses Collection and let the API name autofill.
    3. For Variable, select the **EmailAddresses** collection variable you created.
    4. For Operator, select **Add**.
    5. For Value, select **Current Item from Loop** and then select **Email**.
        
        This takes the email of the current contact you're on, and adds the email of that contact to the EmailAddresses collection variable.
4. Add a Send Email action.
    
    This step configures the email to send to the selected contacts.
    
    1. For Recipient Address Collection, select the **EmailAddresses** collection variable.
    2. In the Configure Email Content section, for Subject, enter Welcome to Our Community!.
    3. For Body, enter We're excited to welcome you as a new contact. If you have any questions, feel free to reach out!.
    4. For Rich-Text-Formatted Body, select **True**.
        
        This step makes the email look nicer by using the selected font and any other formatting you're configured.
    5. Save your work.
    
    ![Configured Send Email action element](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/example_screen_action_send_email.png)
    
    Now the flow is configured to send the email to the contacts selected on the screen.
    
    ![Full flow](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/example_screen_action_full_flow.png)
5. Test your flow using sample data and different scenarios and then activate it.