Salesforce Dynamic Forms
Dynamic forms are probably one of the most exciting new features coming to Salesforce in the Summer ‘20 Release.
We’ve been hearing about dynamic forms for some time now, but they were always the talk of the future.
But not anymore. Dynamic forms are finally here, and they are here to stay (because they are awesome).
If you haven’t heard about dynamic forms before, you might be a bit confused about all this excitement. So here’s an explanation why they are such a great enhancement.
The basic way to manage which fields are visible on a record page are page layouts. Thanks to profiles we can configure them so that different fields are visible to different users. In most cases, that works just fine. But sometimes, we might have more specific business requirements, e.g. we have a field or a set of fields that we would like to move somewhere else on the record page or hide them depending on some criteria.
How could we tackle those two issues?
In the case of moving certain fields across a record page, it’s going to be difficult but possible (to some extent). Page layouts are inseparable blocks of fields so we can’t simply move a field. One solution to work around this issue is to use the Related Record component. It allows to bring fields from the same or related record using actions. But it’s not very flexible, can be buggy, and the loading times can be quite long if we use more than 8 fields.
How about hiding a field? The solutions here seem kind of obvious. We can create a second page layout (but we could end with multiple page layouts for different users). Or define the access to that field with permission sets. But what if we want this field to stay hidden only under certain conditions such as another field’s value?
As you can see, page layouts, as nice as they are, can’t handle all types of situations.
That’s where the dynamic forms come in.
Why You Should Use Dynamic Forms
Before we start upgrading our old-fashioned record pages, let’s take a look at the short summary of all of the benefits of dynamic forms.
Don’t be limited by page layouts aymore. With dynamic forms you can break out fields into sections and place them wherever you want.
You can set up visibility rules for individual fields or whole sections. You can show/hide fields depending on the value in another field, device, custom permission or user.
Better page performance
Because this isn’t just about doing something that couldn’t be done before. By putting fields into accordion components or tabs you can seriously improve page load times.
Better layout management
No need for page layouts anymore. You can manage fields on your pages in the Lightning App Builder alone. Without the need to assign page layouts, organizing field visibility for users becomes easier for admins.
How to Use Dynamic Forms
To enable Dynamic Forms go to Setup under Record Page Settings and switch on the toggle button. And here’s the catch - this feature is only available for custom objects as of now. The support for standard objects is on the Lightning Experience Roadmap but without any specifics about when it will be available.
Now, let’s go to the Lightning App Builder. You can create a new lightning record page or edit an old one, but I highly recommend creating a new one from scratch to see how this process works.
For the existing pages Salesforce implemented a special function that allows you to upgrade old record pages to dynamic forms automatically. Just click the Record Details component and look for the “Upgrade Now” button that should be visible at the top of the properties pane on the right hand side, and follow the instructions.
Let’s look at how dynamic forms work when creating brand new pages.
You should see an additional tab labeled “Fields” available in the left-hand components pane. That’s where you find all the fields available for putting on the page. Before you drag any of them onto the page, you need to use the “Field Section” component to create an area when you can place your fields. This process is very intuitive and doesn’t require any real training.
You can configure the UI behavior (read-only, required) for each of the fields the same way it’s done in the page layout editor. Furthermore, you can set the field visibility, which I’ve mentioned before. It can be very useful.
Remember that you can also place field sections in tabs. It’s a good way to make the record page more compact.
What about Mobile?
An important question remains - how dynamic forms work on mobile?
Unfortunately, the new “Field Section” component is not available on mobile yet. To display the fields for mobile users use the “Record Detail - Mobile” component. It wraps fields from the page layout.
Salesforce dynamic forms are an exciting feature that lots of admins have been waiting for. It brings a new level of experience to users and gives a lot of flexibility for administrators.
So, does it mean that page layouts have become obsolete?
Although dynamic forms are exciting, there are still a lot of reasons to use page layouts.
First of all, dynamic forms are only available for custom objects. Support for standard objects is on the roadmap, but it will take time before it’s implemented.
Secondly, “Field Section” component isn’t supported on Mobile. We still need to configure the page layout so the “Record Detail - Mobile” component displays the right fields.
And finally, even on custom objects, it’s the page layouts that control the related lists.
Dynamic forms are awesome, but let’s keep in mind that we still need page layouts for a number of reasons.
Here are the official release notes on Dynamic Forms.
Bonus - Extended Record
But wait, there's more!
We’ve covered the dynamic forms but there’s another new feature that should come in very handy when creating lightning record pages.
It’s something called Extended Record.
With the new release we can use the Related Record component to display fields from a record related to the related record.
Does your brain hurt from trying to figure out what that means? No worries, we’ll go step by step on how to use this feature.
We are going to modify our lightning record page for Opportunities to see the details of the parent account.
The Related Record Component enables us to look up the fields on the related account.
With the Extended Record we are able to to go a level deeper and look up the parent account to that related account.
Let’s do it.
1. Create a new action on the Account object. Make sure to choose “Update a record” as the action type.
2. After saving, a page layout editor will open up. Drag and drop the fields you want. Just remember that Salesforce recommends no more than 8 fields to reduce loading times.
3. After you are done, go to Opportunity object and create/edit your lightning record page. We are going to place the fields in an additional tab. In the “Tabs” component click Add Tab and move a “Related Record” component into the new tab.
4. Click the “Edit Lookup Field” button in the right-hand navigation pane and configure it.
5. Pick the Update Action you’ve created in the first step.
And done! If there is a related parent account linked to our opportunity record we will see the additional fields.
Like I mentioned before, the performance depends on the amount of fields we’ve added to the action. So it’s a good idea not to go overboard and choose just the key fields.
This feature can really boost productivity for your users, so make sure to give it a shot!
Click here to see the official release notes.