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(
IsWon,
ISBLANK(Contract_Signer__c)
)

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. There are ways to handle this in the Path, but they feel a bit kludgy.

In dynamic forms, when I move to Closed Won, the field then appears as required, creating a slicker UI. 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.
  • Behind the scenes, changing the stage to Closed Won hides one field and shows another as required.

You may still need the validation rule if Users update the stage via the Path or through automation/API updates.

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.

FAQs

What is a DNS record?

A DNS record is an entry that links a domain name to its IP address, enabling devices to connect 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?

IP warming is the gradual process of building a positive sending reputation to ensure emails reach inboxes and avoid spam.

What is an ESP?

An Email Service Provider offers email marketing and communication services to businesses and individuals. ESPs provide the infrastructure, tools, and services needed to create, send, and manage email campaigns.