Skip to main content
  1. Salesforce.com/

Dynamic Forms for Detail Views in Salesforce

·3 mins

Salesforce UI configuration has been straight forward -

  1. Create a Page Layout for an object (and assign that to profiles/permission sets)
  2. Add button/action link/other controls to layout
  3. Add fields

Salesforce shows the “proven”, “battle tested”, two-column layout for the fields and that was that. You control who sees what primarily through layouts.

Lightning UI brought a few modern elements to the mix (e.g. you can have nicer looking headers, more elements, and the works), but the basic layout remained the same. You still rely on the layout for the finer details of showing the controls.

lightning-record-page-layout

For e.g. let us say sales and service departments create new accounts in an org, but enter different details while creating the account. We personalise the user experience by -

  • Creating Account Sales Layout and Account Service Layout
  • Provide different controls in each layout
  • Assign them to Lightning record pages

You control how different users see the specific layouts through the layout assignment or assignment of lightning record pages to specific profiles.

While this works, we have -

  1. Complexity in creating different layouts for the same purpose
  2. Additional maintenance

All that will change with dynamic forms. Available for custom objects in Winter ‘21, Dynamic Form and Dynamic Action features bring the much needed “dynamic” behaviour to controls (buttons & fields). You can now conditionally show controls based on profiles on a single form.

Enabling a dynamic form is simple -

  1. Go to a specific lightning record page
  2. Click on the Record Detail component
  3. Click on the button to upgrade to dynamic form
  4. Choose a specific layout to upgrade and create a dynamic form

record-detail-page-update-dynamic-form

Once done you will be able to select individual buttons, action links or fields and set attributes on them -

  1. Make fields read-only
  2. Make fields visible based on users or permissions
  3. Enable field visibility to be affected by record data value

dynamic-form-salesforce

In this new world -

  1. You can make controls appear or disappear based on users, permissions or record-level data without duplicating layouts
  2. You can also use this arrangement to specify read-only or required at the UI level

You would have taken note that the field-level permissions extend the component-level permissions available at the lightning component level within the record page. You can show or hide entire section with the same filters.

Also take note there is no “downgrade” button to go back to the old world. But, you can always delete sections / add the Detail component back to stop using dynamic forms.

The UI dynamic form behaviour looks quite basic at this time, but I am happy about the direction of Salesforce UI configuration. I look forward to the functionality getting more focus and enhancements as we get into future releases - all while simplifying implementation and maintenance requirements. At this time I am happy to recommend dynamic forms for the most basic UI functions for an existing layout in custom objects. I would continue creating layouts for anything more complex for now.