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!