In our Salesforce org, the sales team wants to collect customer feedback after an Opportunity is closed. They need a dynamic form with field visibility that changes based on whether the opportunity is closed, won, or lost.
For this requirement, we created the required fields in the Opportunity object and then created dynamic forms so that users see only relevant fields according to stage name (closed won or closed lost).
In this Salesforce tutorial, I will explain dynamic forms and how to create a dynamic form in Salesforce Lightning. For this example, I will use Salesforce’s dynamic forms to display fields based on the opportunity stage.
What are Dynamic Forms in Salesforce?
In Salesforce, dynamic forms are used to customize the page layouts of the record detail page of objects that contain fields and sections.
Using dynamic forms, we apply filter criteria to the fields and sections to show or hide them on the record page, which is not possible using page layouts. Hence, this feature is considered dynamic and provides more control over the fields and sections in the object record page.
Availability of Dynamic Forms for the Salesforce Objects
In Salesforce, dynamic forms are available for all custom objects. Until Dreamforce ‘22, this feature was available only for custom objects; however, it became available for LWC-enabled standard objects, such as Accounts, Contacts, Leads, Cases, and Opportunities, after that.
Dynamic Forms are unavailable on objects that do not support Lighting Web Components, including Campaigns, Tasks, and Products.
Set up and Create Dynamic Forms in Salesforce
To create the dynamic forms, navigate to the LWC-supported object tab (required) and follow the steps below. In this example, I will navigate to the Opportunity tab.
- In the Opportunity object tab, select any record to navigate to the object record page.
- On the object record page, click on the settings icon at the top, then select Edit Page.
- Now, the record page will open in the Lightning App Builder. In the app builder, click on the Details tab of the record page, then on the right-hand side, click on the button Upgrade Now.

- As we click on Upgrade Now, the dynamic forms window will appear on the screen, displaying the features of dynamic forms. Here, click on the Next button.

- In this window, activate the checkbox Migrate fields and sections into an Accordion component to improve page performance. After this, select the page layout and click on the Finish button.

As we click Finish, the dynamic forms will be enabled for the selected object.
Add Visibility on Fields in Salesforce Dynamic Forms
To add conditional visibility to the fields in the dynamic forms, select the fields and then click the Add Filter button in the right sidebar. Select the Field, Operator, and Value there, then click the Done button.
In this example, I have added visibility for the custom field Satisfaction Rating. To make this field visible in closed-won opportunities, I have selected ‘Field’ as the Stage, ‘Operator’ as ‘Equal’, and ‘Value’ as ‘Closed Won’.
After adding visibility to the field, the visibility icon
will appear.

We can add component visibility on fields in Salesforce dynamic forms with this.
Add Visibility on Components in Salesforce Dynamic Forms
In Salesforce dynamic forms, we can add conditional visibility to the components. For example, you have to add the same conditional visibility on all fields on a component. Then, instead of adding visibility to fields separately, we can add visibility on the component itself.
From the Fields in the left sidebar, drag and drop the Field Section to the Page Layout. After that, add the fields to the component to which you want to add the same visibility.

Now, select the component to go to the right sidebar, and click on the button Add Filter under Set Component Visibility.
In this example, I have set the component visibility for closed opportunities. For this, I have set the Field as Stage, the Operator as Equal, and the Value as Closed Lost.
After selecting the filter conditions, click on the Done button.

This way, we can add visibility to the components in Salesforce dynamic forms.
Set Highlight Panel in the Salesforce Dynamic Forms
To add a Highlight Panel in the dynamic form, drag the dynamic Highlights field panels component to the page layout.

After this, add fields in the Highlights Panel. You can add custom and standard fields and components to this.

We can also set the conditional visibility for the Highlight panel and its fields as we have done for the fields and components in the above sections.

This way, we can add a highlights panel in Salesforce dynamic forms in Lightning.
Enable Dynamic Forms on Salesforce Mobile App
To enable the dynamic forms for the Salesforce mobile application, navigate to the setup page of Salesforce Lightning.
On the setup page, go to the Quick Find box and search, then select Salesforce Mobile App.

In the Salesforce Mobile App setup, activate the slider button for Dynamic Forms and Dynamic Highlights Panel on mobile.

This setting will also enable dynamic forms for Salesforce mobile applications.
Conclusion
This way, we can enable and create dynamic forms in the Salesforce lightning experience. With this, you can make your lightning forms dynamic and add conditional visibility to the fields and components. In the dynamic forms and conditional visibility, you can also create \the sections and arrange the fields anywhere on the object page layout.
In this Salesforce tutorial, we have also learned about the dynamic forms in Salesforce and how we can enable the dynamic forms for the Salesforce Mobile Application.
You may also like to read.
- Build Custom Record Page for Mobile App in Salesforce Lightning
- Create a Custom Lightning Record Page in Salesforce
- Create Lightning Page Tabs in Salesforce
- Salesforce Page Layouts
- Global Publisher Layouts in Salesforce

Abhijeet is a skilled Salesforce developer with experience in developing and integrating dashboards, data reports, and Salesforce applications. He is also skilled at optimizing processes and flow automation processes, coding, and executing complex project architecture. Read more about us | LinkedIn Profile.