How to Dynamically Require Fields Using Salesforce Dynamic Forms

Ever since Salesforce released Dynamic Forms I’ve been playing around with ways to use this to improve the user experience. Especially since this was released for standard objects like Account and Opportunity, I’ve been trying to find ways that can make both my life as an admin and a User’s life easier. A common use case that I came across lately, a lot of times people will want to require certain fields be filled out after a certain stage of an opportunity. I want to demo one of these examples with both how it used to be done and how it can be done using Dynamic Forms in a way that I think is slicker.

>> Related: [Salesforce Package] Stamp UTM Parameters on Campaign Members <<


Video transcript:

In this example, I have a field that’s just a look-up to a Contact, called Contract Signer.

And this is required when the Opportunity is Closed Won. Obviously, we can’t have a Closed Won Opportunity if we don’t know who’s going to sign the contract. So typically, this would’ve been accomplished by creating a validation rule that would look something like this:


And then from a user perspective, that would look something kind of like this. I’d go to mark my Opportunity as Closed Won, hit save, and then I’d see that error telling me that this is required. Why this kind of sucks, in my opinion, is that if I’m a user, when I go to move this to Closed Won, there’s no visual indicator to me that this is now required. I just have to kind of know that. While there are ways to address that in the Path a little bit… it’s just kind of kludgy in my opinion.

So how this can be accomplished in dynamic forms is a little bit slicker User interface in my opinion, where, okay, I move to Closed Won, and now you see that this shows as being required. I can populate it, save, and move on with my life. Hooray, exciting.

Behind the scenes, what this looks like is really quite basic. So I’m going to open up my Lightning App Builder here, look at the page. Navigate to my Dynamic Forms tab, and you can see in this Field section, I actually have the Contract Signer field in two different places. This first one here is conditionally visible and has no UI behavior. And this is for if the stage of the record is anything but Closed Won because this is only required when it’s Closed Won. And then this other instance of Contract Signer that I have set to a required UI behavior when the stage is Closed Won. So behind the scenes, what this doing is once I change the stage to Closed Won, this one disappears, this one shows up and is indicated as required.

Now this doesn’t help if you allow your Users to update the stage from the Path, which may mean you still want to have the validation rule for both Users who are updating via the Path and potentially automation or API updates that might be doing the same thing, that you still want to require this. But in my opinion, this is a better User experience. And if you wanted to block Users, for example, from updating via the Path, you can do that by hiding this Path update button. Then this effectively becomes just a visual indicator of what’s happening. And then you can also see any Key Fields and Guidance for Success if you have that configured. But that’s pretty much it and hope you find this useful.


What is a DNS record?

A DNS record, or Domain Name System record, is a data entry in the DNS (Domain Name System) that provides information about a specific domain or hostname. DNS is a hierarchical and distributed naming system that translates human-readable domain names, like, into IP addresses, which are used by computers to locate and connect to each other on the Internet.

What is an ISP?

ISP stands for Internet Service Provider. An ISP is a company or organization that provides access to the Internet and related services to individuals, businesses, and other organizations.

What’s a spam trap?

A spam trap is an email address that is used for the purpose of identifying and monitoring spammers. Spam traps are created and managed by email service providers, anti-spam organizations, and internet security entities. The primary goal of spam traps is to catch and identify senders who engage in unsolicited or spammy email practices.

What does it mean to warm an IP?

Warming an IP address refers to the gradual process of establishing a positive sending reputation for that IP address with email service providers (ESPs) and Internet Service Providers (ISPs). This process is particularly relevant for new IP addresses or IP addresses that have not been used for email sending recently. Warming is essential to ensure that the emails sent from the IP address are delivered successfully to recipients’ inboxes and avoid being flagged as spam.

What is an ESP?

An Email Service Provider is a company or service that offers email marketing or email communication services to businesses and individuals. ESPs provide the infrastructure, tools, and services needed to create, send, and manage email campaigns. | Marketing and Revenue Ops

Get a System Audit

Whether you inherited a new instance or just want a second opinion, we'll dive in and benchmark your tech stack.

  • Hidden
  • Hidden
  • Hidden
  • Hidden
  • Hidden | Marketing and Revenue Ops

Download Resource

Use this form to recieve your free resource in your inbox today!