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
          Create Multiple Records with a Repeater Screen Component Example

          Create Multiple Records with a Repeater Screen Component Example

          This example creates screen flows that use Repeater components to collect information for multiple related items and perform bulk actions on that data. Use Repeater components when you need to gather the same type of information for multiple records, such as collecting product information for multiple items. The flow can then automatically create and link related records based on the collected information.

          Required Editions

          View supported editions.
          User Permissions Needed
          To open, edit, create, activate or deactivate a flow using all flow types, elements, and features available in Flow Builder, including Einstein and Agentforce for Flow: Manage Flow

          This example configures a screen that collects a first name, last name, and email address for each person that's added. The user can add as many family members as needed. After the information is collected, the flow automatically creates a customer account and a contact record for each person entered, all connected to that same account.

          Create a Screen Flow

          Create a screen flow to collect information from your customers.

          1. Open the Flows list view.
            • From Setup, in the Quick Find box, enter Flows, and then select Flows.
            • From the Automation app, select the Flows tab.
            • From the Flows tab in any Lightning app, click the actions menu and select Open Flow.
          2. Create a screen flow.
            • From the Automation app, click New | Screen Automations | Screen Flow.
            • From Setup, click New Flow | Screen Automations | Screen Flow
            The new screen flow opens in Flow Builder.

          Add and Configure a Screen Element

          Add a screen element that contains instructions and a Text component to collect a family name. The family name is used as the account name when we create the account. Then add a Repeater component to show a set of contact fields multiple times on the screen. Because we're collecting first names, last names, and email addresses, add a Name component and an Email component within the Repeater component.

          1. Add a Screen element.
            1. Click Add element plus icon, and select Screen.
            2. For Label, enter Collect Customer Information.
              The API name autofills.
          2. Add instructions and a Text component to hold the family's name.
            1. Add a Display Text component. From the Components list, in the Display section, click Display Text. For API Name enter DisplayInstructions. For the text box, enter Enter a name for your family. Then enter your information and the information for any additional family members you want to add to our list.
            2. Add a Text component. From the Components list, click Text. For Label, enter Family Name. The API name autofills.
          3. Add a Repeater component and child screen components to go in the Repeater component.
            1. In the Components List, in the Display section, click Repeater.
            2. For API Name, enter RepeatCustomerFields.
            3. Add a Name component. From the Components list, drag and drop a Name component into the Repeater component. For API Name enter CustomerName
            4. Style the Name component. Click the Style tab. For Width, select 6 of 12 (Half Width).
            5. Add an Email component. From the Components list, drag and drop an Email component into the Repeater component. For API Name enter CustomerEmail
            6. Style the Email component. Click the Style tab. For Width, select 6 of 12 (Half Width).
            7. Move the Email component to other half of the Repeater component.
          4. Add a default value for the Family Name component to give users an example of what information to enter. The default value is shown in the screen component until the user enters a value.
            1. Click on the Family Name component.
            2. For Default Value, click the Family_Name screen component, and then enter Family. The full default value is {!Family_Name} Family.
          5. Click Done.
            A Repeater component on a screen element

          Add and Configure a Create Records Element for the Account

          Add and configure a Create Records element to create the account record that's related to the new contacts.

          1. Click Add element plus icon, and select Create Records.
          2. For Label, enter Create Account.
            The API name autofills.
          3. For How to set record field values, select Manually.
          4. For Object, select Account.
          5. For the Account Name value, select the Collect Customer Information screen, and then select Family Name.
            This step selects the family name that the user entered as the name of the new account.

          Add and Configure a Loop Element

          Add and configure a Loop element to process the information gathered from the screen element, one family member at a time.

          1. Click Add element plus icon, and select Loop.
          2. For Label, enter Iterate Over Customers.
            The API name autofills.
          3. For Collection Variable, click the Collect Customer Information screen, then the RepeatCustomerFields screen component, and then the AllItems output.
            This step selects the information entered into the Repeater component as the items to loop through.
          Note
          Note This flow uses variables and Assignment elements inside a loop to process the new contact information, rather than a Create Records element. This approach keeps the data processing within the flow until all information is gathered, and then a single Create Records element is used outside the loop to create all contact records as a group. This approach minimizes database interactions and prevents potential errors. For example, think about collecting customer emails at an event by using paper. You could process each customer one at a time: Get their email, go back to your computer, add them to the email list, and then go back to get the next email. But that takes a lot of effort! Or, you could gather everyone's emails first, and then add them all to the email list in one batch later. The second way is much faster.

          Add and Configure a Contact Record Variable

          Add and configure a Record Variable resource to hold contact record field values. The Repeater component doesn't know what kind of information it's collecting, so we must map the Repeater output to a placeholder contact record for each family member that we loop through.

          1. Click Open toolbox and then click New Resource.
          2. For Resource Type, select Variable.
          3. For API Name, enter ContactRecord.
          4. For Data Type, select Record.
          5. For Object, select Contact.
          6. Click Done.

          Add and Configure a Contact Record Collection

          Because we're creating multiple contacts at one time, we need a Record Collection Variable resource to hold the information about all the contacts as a group.

          1. Click Open toolbox and then click New Resource.
          2. For Resource Type, select Variable.
          3. For API Name, enter ContactCollection.
          4. For Data Type, select Record.
          5. For Object, select Contact.
          6. Select Allow multiple values (collection).
            This step makes the variable a collection variable that can hold multiple items, like records.
          7. Click Done.
            Contact record collection variable

          Add and Configure an Assignment Element to Set Contact Record Values

          Add and configure an Assignment element in the loop path to set contact field values for each family member in the loop.

          1. After For Each, click Add element plus icon, and select Assignment.
          2. For Label, enter Set Contact Record Values.
            The API name autofills.
          3. For Variable, click the ContactRecord record variable and then click the Account ID field.
          4. For Operator, select Equals.
          5. For Value, select AccountId from Create Account.
            This step sets the contact's account to the one that we created.
          6. Click Add Assignment.
          7. For Variable, select ContactRecord, and then select First Name.
          8. For Operator, select Equals.
          9. For Value, click Current Item from Loop, click the CustomerName screen component, and then click the First Name output.
            This step sets the contact's first name to the first name the customer enters in the screen.
          10. Repeat steps 6 through 9 for the customer's last name and email. When selecting the value for the email, click Current Item from Loop | CustomerEmail | Value | .
            Set Contact Record Values Assignment element with the field values set

          Add and Configure an Assignment Element to Add the Contact to the Collection

          Add and configure another Assignment element in the Loop path to store the contact field values for each family member in the contact record collection variable. After the contact record values are saved, the contact record variable can be used to store the next family member's information.

          1. After the Set Contact Record Values Assignment element, click Add element plus icon, and select Assignment.
          2. For Label, enter Add Contact to Collection.
            The API name autofills.
          3. For Variable, click the ContactCollection record collection variable.
          4. For Operator, select Add.
          5. For Value, select the ContactRecord record variable that we just populated the fields for.
            This step adds the contact that's in the loop to the contact record collection. Now that those field values are saved in ContactCollection, the ContactRecord record variable is ready to be reused for the next contact's information.

          Add and Configure a Create Records Element to Create the Contacts

          Add and configure a Create Records element to create all of the contacts at once. Because we stored all of the contacts in the record collection variable, we can ask the Create Records element to create records for everything in that collection.

          1. After the Loop and Assignment elements, outside of the loop, click Add element plus icon, and select Create Records.
          2. For Label, enter Create Contacts.
            The API name autofills.
          3. For How to set record field values, select From a Record Variable.
          4. For How Many Records to Create, select Multiple.
          5. In the Select Values to Create Multiple Records section, for Record Collection, select ContactCollection.
          6. Save your flow and give it a descriptive name. For this example, Create an Account and Contact Records for a Family using an Online Form.
          7. Test your flow by using sample data and different scenarios.
          8. When you're ready to activate your flow, click Activate.
          Full flow with all the elements

          The flow is ready to collect information about multiple customers and create an account and multiple related contacts with that information.

           
          Loading
          Salesforce Help | Article