In Salesforce, Screen Flows are a powerful tool for automating business processes through a guided experience for users. With the introduction of Repeater Components, Salesforce has made it even easier to display dynamic, repeated data sets on Flow screens.
Tired of going back and forth to enter details? With the Repeater Component, you can collect multiple records in one go—like adding several contacts without breaking a sweat. And with conditional visibility, only the fields that matter (like a birth date) will show up when needed. This keeps things simple, reduces errors, and makes the whole process feel seamless. Ready to create flows your users will love? Let’s dive in!
Repeater Component
A repeater component is a feature that allows users to replicate input components multiple times within a section. It collects information about various items of the same type on a screen.
Create multiple records: Create numerous records at once
Add or remove fields: Dynamically add or remove contact fields
Streamline data entry: Enter information into multiple record fields on the same screen
Enhance user experience: Simplify contact record creation
Loop over output: Loop over the output of the component and save the relevant data in a variable
Build a list of records: Use the variable to build a list of records
You can control how many times the repeater section appears by setting a predefined number of repetitions or allowing users to add or remove sections dynamically.
Here, I will be adding multiple contacts with optional birth dates to an account and will create a screen flow to show conditional visibility to the repeater component by processing the flow
Adding Multiple Contacts with Optional Birth Date Sharing
In this flow, users can add multiple contacts to an account. For each contact, there is an option to provide a birth date. The birth date field will only appear if the user selects the option to share it, using conditional visibility.
Create a Screen Flow (I named it ‘Conditional Visibility On Repeater Component’)
Using the Get Records element, I retrieved all the account
Add a screen component and name it.
In the component column, search for the repeater and drag it to the screen canvas
Name it (Repeater_Component)
Search for the text element and drag it inside the repeater component.
You can add other fields as per your requirement
In the component column, search for "Lookup" as we are retrieving data from the Account object.
Fill up the details according
To add conditional visibility. I am adding a checkbox. If it is selected, the canvas will show the birth date details. Start by placing the checkbox on the screen component and set the visibility criteria accordingly.
Set visibility criteria
Save and Activate the flow. I am assigning it as org default for now.
Let’s see how the flow will look. Also, have a look at the images below.
Fill up the other details
The ‘Want to share your birth date?’ check it (Make it true).
You can see it's asking for birth details.
Click on the add button. The repeater component benefits you by allowing you to add multiple records of contact.
Loop: Process Each Contact
Once the user submits the form with multiple contacts, the flow enters a Loop to process each contact individually. The flow will iterate over the contacts entered in the repeater, performing the following steps for each contact.
Assignment: Assigning Field Values to the Contact Object
Inside the loop, the flow uses an Assignment element to assign the values from each contact's input to a createContact variable that holds the contact data.
In this step, the following fields are assigned:
AccountId: Assigned from the account lookup field (lookup_to_Account.recordId).
FirstName: Assigned from the contact's first name.
LastName: Assigned from the contact's last name.
Email: Assigned from the contact's email.
Decision: Checking for Optional Birth Date
After assigning basic information to the createContact variable, the flow uses a Decision element to check if the user opted to provide the birth date. This is done by checking the value of the Want_to_share_your_birth_date field.
If the condition is met (i.e., the user checked the box), the flow assigns the birth date to the createContact object.
Assignment: Add the Contact to a List
Once all relevant fields are assigned, the flow adds the createContact variable (which now holds all the contact data) to a listOfContacts collection variable. This collection will store all the contacts that are processed in the loop and will be used later to create all the records at once.
Create Records: Creating All Contacts in Salesforce
Once the loop has processed all the contacts and added them to the listOfContacts collection, the flow inserts all the contacts into Salesforce at once using a Create Records element.
Debug your Flow
Let’s test the scenario. We have created an account ‘Avenoir test’ without any related contacts.
Adding the flow to the Sales App Home Page to test it.
Click on the Add button and fill up the second related contact without the birth date.
Now click on Next and check the account.
So as you can see these are related contacts.
In the related contact section, you can verify the birthdate for each contact. For example, the first test contact has the birthdate field populated, while the second test contact does not. This demonstrates the benefit of using conditional visibility within the repeater component, as it ensures that only relevant fields are displayed based on the data availability.
Conclusion
Adding conditional visibility to Repeater components in Salesforce screen flows enhances the user experience by dynamically showing only relevant fields. This approach simplifies the data entry process, reduces errors, and creates a more interactive flow. Following the practical example, you can implement this feature in your flows and see the benefits firsthand.
If you'd like to see the code and resources used in this project, you can access the repository on GitHub. To access the AVENOIRBLOGS repository, click here. Feel free to explore the code and use it as a reference for your projects.
Thank You! You can leave a comment to help me understand how the blog helped you. If you need further assistance, please contact us. You can click "Reach Us" on the website and share the issue with me.
Reference
Blog Credit:
S. Yadav
Salesforce Developer
Avenoir Technologies Pvt. Ltd.
Reach us: team@avenoir.ai