In Salesforce, we create records with the help of forms, and these forms have various fields and components by adding Component Visibility, where we have to state conditions to control, such as whether a specific field is visible or not on a record page.
In Salesforce Screen flows, we can add conditional visibility to any specific field or component. In this Salesforce tutorial, we will learn to use and add Conditional visibility for components in Salesforce Screen flow.
Flow Conditional Visibility Considerations
For setting visibility for a screen component, there are the following considerations.
- The null value is always evaluated as an empty string.
- Operators like ‘Was Visited‘ and ‘Was Set‘ aren’t supported in conditional visibility.
- The Apex-defined data types and Record variables data types aren’t supported in conditional visibility, but you can reference attributes and fields.
- Any screen input component with Manually assign variables (advanced) selected isn’t available as a resource for conditional visibility on the same flow screen.
- Text that has merge fields included isn’t supported in values. Merge fields on their own are supported.
Create a Screen flow with Component Visibility in Salesforce
In this example, I will create a Screen flow to explain component visibility. With flow, we will create Account records, and there will be two address fields: Billing Address and Shipping address. We will add a condition: if the Shipping address is the same as the Billing address, then the Shipping address section will not appear on the screen.
To create a Screen flow with Component Visibility in Salesforce, navigate to the setup page and follow the below steps.
1. Go to the Quick Find box, and search, then select Flows under Process Automation.
2. In the flows setup, click New Flow. In the next window, select the option Screen flow.
3. Enter the Lable and API Name for the Screen element.
In the screen, we will add fields that will create an Account record and then add component visibility in those fields.
4. Add a Text element to the screen and label it as Account Name. After this, add a Phone element to the screen and enter the Label and API name for that, too.

5. Now, we will add two address components, one for the Billing Address and another one for the Shipping Address. Enter the API Name and Label for both Address components.

6. To add the component visibility to the Shipping address component, we will add a Checkbox component to the screen (above the shipping address component).

7. Select the component on which you want to add conditional visibility and go to the section Set Component Visibility. In the Condition requirements, select the Resource as Checkbox name and Value as false. After this, click Done.
According to this condition, the Shipping address will be visible when the Checkbox is not selected.
At last, click Done to save the Screen.

8. If the user selects the checkbox, the Shipping Address should be auto-filled, and for that, we will add a Decision element with the details below.
- Enter the Label and API Name for the Decision element.
- In the section Outcome Details, enter the Label and Outcome API Name.
- In the Condition Requirements, select the Resource as Checkbox and Value as True.

9. Now, we will create a resource that we will use in the Assignment.
Create a New Resource with the following details.
- Select the Resource Type as a Variable.
- Write APIName as accountRecord.
- Select Data type as Record.
- Select the Object as Account and click Done.

10. Now add an Assignment element to the flow. After this, enter Name and API Name. This assignment element will map the Address fields with their values in flow.
Now map the following Fields with respective values for the Billing Address. In the below mapping, accountRecord is the Record type variable that we created.
| Variable | Values |
| accountRecord > Account Name | Account_Name |
| accountRecord> Billing City | Billing _address > City Value |
| accountRecord> Billing Street | Billing _address > Street Value |
| accountRecord> Billing Postal | Billing_address > Postal Code Value |
| accountRecord> Billing State | Billing_address > State Value |
| accountRecord> Billing Country | Billing Address > Country Value |

11. Map the below fields to fill details of the shipping address from the billing address.
| Variable | Value |
| accountRecord > Shipping City | Billing_address > City Value |
| accountRecord > Shipping Street | Billing_address > Street Value |
| accountRecord > Shipping Zip/Postal | Billing_address > Zip/Postal Value |
| accountRecord > Shipping Country | Billing_address > Country Value |
| accountRecord > Shipping State | Billing_address > State Value |

12. Now, we will configure the decision element’s default outcome when both addresses are different. In the default outcome, copy-paste the Assignment element of the same address.

13. Edit the Assignment element of the Default Outcome and change the Label. After this, update the values for the Shipping address variables.
| Variable | Value |
| accountRecord > Shipping City | Shipping_address > City Value |
| accountRecord > Shipping Street | Shipping_address > Street Value |
| accountRecord > Shipping Zip/Postal | Shipping_address > Zip/Postal Value |
| accountRecord > Shipping Country | Shipping_address > Country Value |
| accountRecord > Shipping State | Shipping_address > State Value |

14. Add a Create Record element and enter Label to create a record element. In the Record field, select the Resource Variable that we have created.

15. Copy the Create Record element and paste it below the Default Outcome’s Assignment element.
16. The flow is completed, Now save it with relevant flow label.
Debug the created Screen Flow
Follow the below steps to check the component visibility in the flow.
1. Click on the Debug button in the flow builder.

2. In the Debug Flow window, click on the Run button.
3. Fill in the details of the Billing address and click on the checkbox Shipping Address same as the Billing Address. As we click on the checkbox, the Shipping Address component will disappear from the screen.

4. At last, click Next to create a record.
Now, in the results, we can see that the Shipping address is filled from the values of the Billing address.

In this way, we can add conditional visibility in Salesforce screen flows by following the above steps.
Conclusion
In Salesforce Screen flows, we can make screen forms more dynamic by adding conditional visibility to the components. In this Salesforce tutorial, we learned the method of adding conditional visibility to the Screen flow component with the help of the above example, where we added conditional visibility to the Shipping Address component in a Screen form.
In the same way, we can add conditional visibility to the Screen flow component in our Salesforce instance, making the flows more dynamic and organized.
You may like to read:
- How to Display Image in Salesforce Screen Flow
- How to use Collection Filter in Salesforce Flow
- Check Duplicate Records Using Screen Flow in Salesforce
- Display Picklist Values by Record Type in Salesforce Screen Flow
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.