Loading
Salesforce now sends email only from verified domains. Read More
Automate Your Business Processes
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Email Contacts that a User Selects on a Screen Example

          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.

          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
          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
          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, clickAccountId, 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.
            A Get Records element that's retrieving contact records with an AccountId that equals inputAccountId
          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
          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

          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

          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

            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
          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.
          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

            Now the flow is configured to send the email to the contacts selected on the screen.

            Full flow
          5. Test your flow using sample data and different scenarios and then activate it.
           
          Loading
          Salesforce Help | Article