back to blog
Add Contacts And Display On Account Page Using Repeater Component In Screen Flow
March 29 2024 • 10 min read

Repeater Component

It gives us a repeatable data entry section that users can repeat “n” times. The user can add or remove section occurrences in runtime on the same screen.

The Repeater Screen component allows you to repeat a set of fields in a single screen element. You can create multiple records from one place without the need to navigate from the screen.

Business Challenge

Users cannot repeat sections consisting of multiple fields dynamically on the screen. Providing this feature helps users from navigating multiple screens to achieve it. For example, creating multiple contacts to an account needed to navigate through the “New Contact” screen several times.

Repeater Screen Component empowers users to add or update multiple records dynamically, such as contacts, cases, or opportunities, within a single interface. 

With its intuitive design and seamless integration, the Repeater Component streamlines data entry processes, enhancing efficiency and productivity. 

Requirement

We need to create a screen flow which mainly uses a repeater component to add multiple contacts dynamically in one screen and display the newly created contacts on the account page. The screen should have “add” and “remove” buttons. 

By clicking add, the sections which contain multiple fields are repeated. It can be repeated n times by clicking the add button. By clicking the remove button the data entry section is removed. Upon clicking Next, the entered contacts are saved and displayed on the account page.

Steps to achieve the Requirement

  1. Create a Screen Flow
  2. Create Repeater Component and add to the screen 
  3. Create a Loop
  4. Add an Assignment element
  5. Add a Create Record element to create Contacts
  6. Test the Flow
  7. Features of Repeater Component
  8. Comparison of Data Table and Repeater Component

1. Create a Screen Flow

1.1. Login to Salesforce, and in your Salesforce org click the Gear icon and select Setup.

r1 1

1.2. In the Quick find box find and click the Flows and then click New Flow.

r1 2

1.3.Click the Screen Flow and then click Create.

r1 3

2. Add a Screen element and add Repeater Component inside the screen

2.1. Click the (+) icon below the Start element.

r2 1

2.2. In the Search box type Screen to add the Screen elements and click it.

r2 2

2.3. Give the Screen Label as Contact Information.

r2 3

2.4. Drag And drop the Repeater Component inside the Screen Component and give the API name as Repeat_Contact and click Done.

r2 4

2.5. Drag and drop the Text Component inside the Repeater Component and Label it as First Name.

r2 5

2.6. Again drag the drop the Text Component inside the Repeater Component and Label it as Last Name.

r2 6

3. Create a Loop

3.1. Click the (+) icon below the Screen element.

r3 1

3.2. In the Search box, search for Loop and select the Loop Element.

r3 2

3.3. Label the loop For Each Contact, and choose the Collection variable as shown below

     3.3.1. Repeat_Contact.AllItems

r3 3

4. Add an Assignment element

4.1. Click the (+) icon below the Loop element.

r4 1

4.2. In the Search box, search for Assignment and select the Assignment element.

r4 2

4.3. Label the Assignment element as Add all Contacts.

r4 3

4.4. Create a New Resource with API name as ContactRecord

     4.4.1. The Resource Type is Variable

     4.4.2. Choose the Data Type as Record, and choose Contact as Object

r4 4

4.5. Again create a New Resource with API name as AllContacts

     4.5.1. The Resource Type is Variable

    4.5.2. Choose the Data Type as Record, and choose Contact as Object and enable  the Allow multiple values checkbox, and then click Done

r4 5

4.6. Set the variable values.

   4.6.1. ContactRecord.FirstName ->Equals ->For_Each_Contact.First_Name

   4.6.2. ContactRecord.LastName -> Equals ->For_Each_Contact.Last_Name

   4.6.3. Create a New Resource with API Name as recordid

         4.6.3.1. The resource Type is Variable

        4.6.3.2.The Data Type is Text and Enable  the Available for input checkbox and then click Done.

r4 6

     4.6.4. ContactRecord.AccountId ->Equals ->recordid

     4.6.5. AllContacts ->Add ->ContactRecord

r4 7

5. Add a Create Record element to create Contacts

5.1. Click the (+) icon below the After Last in Loop element.

r5 1

5.2. In the Search box type  Create Record to create Contacts and then click Create Records element.

r5 2

5.3. Label the record as Create Contacts.

     5.3.1. Enable the Multiple Records to Create checkbox

     5.3.2. Choose the Record Collection as AllContacts.

r5 3

5.4. Save the Flow with flow label Create Contacts Using Repeater.

r5 4

6. Test the Flow

6.1. This is the Screen Flow which uses the Repeater component to display the newly added contact in the account page.

r6 1

6.2. There are no contacts under this particular account.

r6 2

6.3. Now click on the debug option to test the flow.

r6 3

6.4. Mention the particular recordid on which account page the contact needs to be added and click on Run.

r6 4

6.5. An empty contact form appears with fields First Name and Last Name.

r6 5

6.6. Now click on the Add button.

r6 6

6.7. By clicking Add, the sections which contain fields we added are repeated, now click the Remove button.

r6 7

6.8. Now three Contacts are Created by clicking the Add button with Name Test A1, Test A2, Test A3, and then click Next.

r6 8

6.9. The flow is tested successfully with no error.

r6 9

6.10. Now the three newly created contacts are saved and displayed in the particular account page.

r6 10

7. Features

  • Using the Repeater component in a screen flow, it is possible to create, edit or delete multiple records within a single flow screen.

    r7 1

  • You can configure header and footer with different custom labels.

    r7 2

8.  Comparison of Data Table and Repeater Component

r8 1

Leave a Comment

Your email address will not be published

© 2024 Digital Biz Tech