Validation rules are a wonderful way to instill best practices, reinforce business processes, and help with keeping data entry consistent and clean. They can also make integration, deployments, data loads, and user experiences miserable.
A well-meaning admin can grind the wheels of automation and integration to a halt by inserting a needed validation rule without looking at all the implications. At the same time, users loath hitting save and seeing red error messages and pop-ups blocking them from completing their work.
Luckily with Lightning Components we can create proactive coaching experiences for users vs reactive validation rules, all with the help of conditional filtering.
Universal Containers wants users to add products to opportunities before moving to the second stage of an opportunity. They have a rollup summary field (Products__c) that counts the number of product records and a validation rule that prevents users from moving to Stage 2 if that field is less than 1.
However, reps edit their opportunities and enter a lot of information only to encounter a validation error that requires them to cancel their edit and go to the related lists tab, losing their work.
Sales leadership has asked you, the rockstar Salesforce Admin, to come up with a proactive solution to save time, effort, and frustration. Luckily, you have just the trick with conditional rich text components!
- Create a field that captures your validation criteria – I say this because its sometimes easier to reference formula field, checkbox field, etc in conditional components then building out your validation logic in that window. In our use case, we are simply using a rollup summary field that counts opportunity products.
- Add a Rich Text Component – add the component and enter the message you want to show users when the record will encounter a validation error based on record attributes. Pro Tip – you can copy and paste gifs into rich text components.
- Make your RT Component Conditional – use the component filter so your rich text component only appears when your field from #1 meets what would normally be your validation criteria.
- Drive the point home (optional) – sometimes users may need some extra prompting and we got a fix for them too. For this use case, when a user insists on going to stage 2 without adding products, we hide all record tabs and display a single ‘Opportunity Product’ related list – prompting users to enter a product to continue with their opportunity.
Add Your Control Field – in this use case, we use a RUS that counts products
Add your Rich Text Component – Include your proactive message and maybe some flashing red lights for emphasis 🙂
Make your Rich Text Component conditional on your criteria field, so its only there when the record is not following the guidelines.
Annddd lastly…if you really want to enforce your rules, give them no other choice. Make every other component conditional and use Quick Actions + Related Record Components or in this case a Related List – Single Component to only allow them to complete the edit you want.
Note my filter below – if they progress beyond Stage 1 and products are less than 1, they get this product list and nothing else!
That’s because all my other components are filtered to disappear when Products is less than 1 and Stage is greater than Stage 1!
Check it out in action – that senior sales rep thinks he can just skip your warning message? Nope, because you SHUT IT DOWN! Admin 2, Rep 0.
Click to save the Flashing Red Light!
I love conditional components and was showing off at my Lightning Champions presentations since last August. In WI19 we get the option to make the conditional on Permission Sets, which adds another layer of flexibility.
Me too! We came up with a client solution the other day in 5 minutes using conditional components that would have taken hours of code to resolve.
We use conditional components extensively on home pages and we love them! They eliminate the creation and maintenance of multiple pages and saves us hours.
You are right – think about how many page layouts, record types, visualforce pages, etc can be avoided with some creative component usage.
I like that use of the GIF’s in the Rich Text Component would be nice to know on how to do it.
Copy and paste! I was pretty amazed when someone showed me, I had no idea it was that simple.
Hi! I’m trying to setup a rich text field similar to yours with the flashing lights. Can you advise where you found those? All the ones I try are inserting too many characters into the field and it won’t save. Thanks!
Sorry for the slow response – sent an email with the image.
Can I get the image aswell please? 🙂
I’m adding to the post!
how did you add the image to the RICH TEXT Component?
Read carefully: Pro Tip – you can copy and paste gifs into rich text components.
Hi, I read and tried to cop paste it, but I was not successful. No option to paste and ctrl-v did not work… Could you try in your org now, perhaps some changes were made that make it impossible now 🙁
Love the last comment.
How exciting that we can copy and paste GIFs into SalesForce! Any recommendations where to find animated icons like the siren above?
Wouldn’t this break if someone was just editing the record in a list view?