Create Dynamic Forms in Salesforce [Complete Guide]

In Salesforce, managing large page layouts can become difficult as the number of fields increases. Users often feel confused when they see too many irrelevant fields. This reduces productivity and increases errors.

This is where Dynamic Forms in Salesforce come into play. Dynamic Forms allow you to show or hide fields based on conditions like record data, user role, or stage.

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 the relevant fields based on the stage name (closed won or closed lost).

In this article, I will explain how to create a dynamic form in Salesforce. 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 record detail page layouts of objects that include fields and sections.

Dynamic Forms is a feature in Salesforce Lightning that lets you control field and section visibility directly in the Lightning App Builder.

Instead of showing all fields at once, Dynamic Forms display only relevant information based on conditions. This makes the user interface cleaner and more efficient.

Dynamic Forms help create user-centric pages where users see the right data at the right time.

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.

Key Benefits of Dynamic Forms in Salesforce

Dynamic Forms are very useful in real-world Salesforce implementations. Let’s understand their importance in detail.

  1. Better User Experience
    • When users see only relevant fields, it becomes easier for them to focus on their work. They do not need to scroll through unnecessary fields. This reduces confusion and improves efficiency.
    • For example, a sales user does not need to see backend or technical fields. Dynamic Forms ensure they only see what matters.
  2. Increased Productivity
    • Less scrolling and faster data entry.
  3. Flexible UI Design
    • Dynamic Forms allow you to place fields anywhere on the page. You are not restricted to a fixed layout.
  4. Reduced Page Layouts
    • Earlier, admins had to create multiple page layouts for different profiles. With Dynamic Forms, you can manage everything in one place using visibility rules.

Dynamic Forms vs Page Layouts in Salesforce

Dynamic Forms solve the problem of cluttered layouts and provide more control over field visibility.

FeatureDynamic FormsPage Layout
Field visibilityConditionalStatic
FlexibilityHighLimited
User experienceBetterCluttered
MaintenanceEasyComplex
UI customizationAdvancedBasic

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.

  1. 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 the Details tab on the record page, then, on the right-hand side, click the Upgrade Now button.
How to create dynamic forms in Salesforce
  1. When we click Upgrade Now, the dynamic forms window appears, showing the features of dynamic forms. Here, click on the Next button.
Enable dynamic forms in Salesforce Lightning
  1. In this window, select the checkbox labeled “Migrate fields and sections into an Accordion component to improve page performance.”
    • After this, select the page layout and click Finish.
Create dynamic forms in Salesforce

As we click Finish, the dynamic forms will be enabled for the selected object.

1. 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 dynamic forms in Salesforce will appear.

Add conditional visibility to fields in Salesforce dynamic forms

We can add component visibility on fields in Salesforce dynamic forms with this.

2. 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 to 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 you want to give the same visibility.

Set component visibility in Salesforce dynamic forms

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 to Stage, the Operator to Equal, and the Value to Closed Lost.

After selecting the filter conditions, click on the Done button.

Salesforce lightning set visibility in dynamic forms

This way, we can add visibility to the components in Salesforce dynamic forms.

3. 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.

Add highlights panel to Salesforce Dynamic forms

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

Highlight fields in Salesforce Dynamic forms

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

Salesforce Lightning Dynamic Forms

This way, we can add a highlights panel in Salesforce dynamic forms in Lightning.

4. Enable Dynamic Forms on Salesforce Mobile App

To enable dynamic forms in the Salesforce mobile application, navigate to the Salesforce Lightning Setup page.

On the setup page, open the Quick Find box, search, then select Salesforce Mobile App.

Enable dynamic forms for mobile application in Salesforce

In the Salesforce Mobile App setup, enable the Dynamic Forms and Dynamic Highlights Panel on mobile.

a close-up of a phone

This setting will also enable dynamic forms for Salesforce mobile applications.

Frequently Asked Questions

1. What are Dynamic Forms in Salesforce?

Dynamic Forms is a feature that lets you control field visibility dynamically in the Lightning App Builder. It helps show only relevant fields based on conditions.

2. What is the main benefit of Dynamic Forms?

The main benefit is improved user experience. Users see only the required fields, reducing confusion and increasing productivity.

3. Can we use Dynamic Forms in Salesforce Classic?

No, Dynamic Forms are only available in Lightning Experience.

4. Are Dynamic Forms better than Page Layouts?

Yes, Dynamic Forms are more flexible and user-friendly compared to traditional page layouts.

5. Do Dynamic Forms improve performance?

Yes, because only relevant fields are displayed, reducing unnecessary load.

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.

Dynamic Forms in Salesforce are a powerful feature that enables the creation of flexible, user-friendly interfaces. They enable admins to dynamically control field visibility, improving both usability and productivity.

If you are still using traditional page layouts, it’s time to upgrade and take advantage of this modern Salesforce feature.

You may also like to read.

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

Salesforce flows complete guide

FREE SALESFORCE FLOW EBOOK

Learn how to work with flows in Salesforce with 5 different real time examples.