Salesforce Dynamic Forms: How to Get Started?

Salesforce Dynamic Forms improves the productivity of organizations and provides users only what they require, transforming static data entry into an intuitive experience. Plus, dynamic forms can be configured easily without complex code. In this article, we will discuss what Dynamic Forms are, where they can be useful, and provide you with a step-by-step guide on how to get started with Dynamic Forms.

What are Dynamic Forms?

The goal of Dynamic Forms is to create user-friendly, intuitive Page Layouts that display the right information at the right time. As often happens when projects expand, the number of fields increases, as a result, the Page Layout or its sections are overloaded with those fields. All of those fields might be needed, but not right now, and not for all users. Previously we used to create several Page Layouts and various Profiles, which required extra effort.

But now Dynamic Forms help us to avoid those efforts. With the help of Dynamic Forms, we can:

  • Place fields anywhere on the Page Layout, not just in the “Details” tab;
  • Use Visibility Rules to set criteria by which fields are shown and hidden;
  • Ability to use one Page Layout instead of several;
  • Improve page load time.

Dynamic Forms is supported on record pages for custom objects, accounts (including personal accounts), contacts, opportunities, cases, and leads only.

How to get started with Dynamic Forms?

To get started, enable Dynamic Forms in the organization:

  • In Setup, in the “User Interface” menu, select the “Record Page Settings” submenuRecord Page Settings
  • In the Dynamic Forms section, switch the toggle switch to Onswitch to On

Enable this on every organization/sandbox you use Dynamic Forms on.

dont miss out iconDon't forget to check out: Dynamic Forms in Salesforce - Tips and Considerations

What will we Implement using Dynamic Forms?

Here is an example that is supposed to help you understand what Dynamic Forms is.

So, we have a custom object with fields

Mandatory:

  • Name
  • Stage (Picklist)

Optional:

  • Rejection reason (Picklist)
  • Other rejection reason (Text)
  • Change address? (Checkbox)
  • City
  • Street

When the Stage value is rejected, the rejection reason field is displayed to the user.

If the value of the rejection reason field is other, then the following text appears to be filled in - other rejection reason.

If the value of the rejection reason field is the wrong address, then the user will see one more field - “Change address?”. If it is set to True, then a new section appears - Address with two fields: City and Street.

Creating a Lightning Page Record with Dynamic Forms

With Dynamic Forms, fields, and sections can be placed anywhere on the page to effectively structure and organize information. In addition, rules can be set to show only certain fields based on other field values, such as when a checkbox is set or when a picklist has a certain value. Also, you can customize the display of data to users based on their role, location, or other identifying information.

So, open the menu Setup - User Interface - Lightning App Builder.

Create a new page: New - Record Page - fill in the Label of the page, specify the custom object in Object, select the page template - Finish. Then we’ll see a Lightning Page available for filling. And the first thing that catches your eye is the Fields.

Create a new page

There are two ways to get started with Dynamic Forms. For new record pages is right after the page has been created. You can immediately drag the Field Section components and Fields onto the page. As Dynamic Forms is very flexible, you can rearrange, organize, and even place sections in different Tabs on the page.

A ways to get started with Dynamic Forms

Alternatively, open an existing page in Lightning App Builder and click on the Record Detail component. In the components properties, you will see a new area.

A ways to get started with Dynamic Forms

Click "Upgrade Now" to get started with Dynamic Forms on this page. A pop-up window will open. Select a page layout there, and then the migration wizard will be launched, which will transfer all the fields and sections to the Lightning Page itself.

A pop-up window

The “Record Detail” component is removed from the page, leaving us with fields and sections that can be customized and placed anywhere.

The “Record Detail” component is removed

Now let's create our page using Dynamic Forms according to the conditions above.

In the Information section, let's leave 2 columns with fields: Name, Stage, rejection reason, other rejection reason and Change address?. The rest let’s delete.

Creating a page using Dynamic Forms

We only need to see Name and Stage constantly, and they must be mandatory. Set this in the properties of the field on the right, which will appear when you click on each of the fields.

Now let’s get started setting Visibility for rejection reason, other rejection reason and Change address? fields. To do this, select each field and in its settings on the right in Set Field Visibility, and click the Add Filter button.

dont miss out iconCheck out another amazing blog by Sparkybit here: What are Salesforce Dynamic Actions: Overview, Benefits, Business Cases

The rejection reason field will only be visible when the Stage field's Picklist value is rejected:

Setting Visibility for rejection reason

Same for other rejection reason and Change address? fields. There can be several filters.

Now let's add the Address section with two fields: City and Street. And set the visibility of the entire section only when the Checkbox fields Change address? set to True.

Save and activate the page. And we can enjoy the result of working with Dynamic Forms.

Only the two required fields are initially displayed.

Only the two required fields are initially displayed

And, depending on the values of some fields, the number of fields on the page increases dynamically.

In this case, you do not need to press the Save button. But it is necessary to display the section.

After saving

After saving

What is Not Supported?

  • Currently Dynamic Forms is supported on record pages for custom objects, accounts (including person accounts), contacts, opportunities, cases, and leads only.
  • Dynamic Forms are not supported on post pages that use pinned-region or custom page templates
  • Field Section and Field components are not supported on mobile devices. All migrated pages will automatically have a new “Record Detail – Mobile” component added, and you must add this component manually if you are creating a page yourself (from scratch) without migrating the old one.
  • Traditional Page Layouts will still control related lists, such as the order of related lists and visible columns in related lists

Conclusion

We consider Dynamic Forms to be a useful tool that developers will soon use more and more. Talking about cons: I did not like that the new section is displayed only after saving the entry. And if you need to change the values of the fields in the new section, you will have to save the record twice. Although it is possible to place formula fields in the new section.

Sparkybit is Salesforce consulting and development company. We make Salesforce perform at its best by fitting it to Clients’ custom business needs. 9 years of sharpened expertise, 25+ successful long-term projects globally.

[email protected]

Copyright belongs to Sparkybit GmbH, Im Dörener Feld 3, 33100, Paderborn, Germany.
2023 © Sparkybit. All rights reserved.

Responses

Popular Salesforce Blogs