Garbage in, garbage out (GIGO). If poor quality data goes into a system, poor quality outputs will come out. Validation Rules are a key part of your Salesforce toolkit to improve your org’s data quality. In this post, I shall cover:
- What are validation rules?
- Why should you use them?
- How to create validation rules
- Examples of validation rules
- Tips for your validation rules (do’s and don’ts)
What are validation rules?
Validation Rules check that the data entered meets conditions you define. If not, the validation rule prevents the data being saved and shows an error message of your choice. This can be used for a variety of scenarios.
A common example is to prevent a user updating a field, without filling in another. In this example, I created a rule which prevents the Lead Status being set to ‘Qualified’ without ensuring the ‘Title’ field is also populated.
The logic behind this validation rule is as follows:
AND( ISPICKVAL(Status, 'Qualified'), ISBLANK(Title))
As both the lead status and title fields meet the rule criteria, it is ‘true’. This triggered the rule, prompting the user to populate the title field.
Why should you use them?
The rule above is simple, but shows how useful validation rules can be. Every business is different. The data you need to capture, process and output also differs. Despite this, poor quality data will almost certainly harm your org.
Let’s assume your business uses mail merging tools to send contracts. Within the template, there are conditional sections which appear based on Salesforce data. This saves your team time and effort. However, if fields are not populated as expected, this could go awry. This is an example of GIGO: poor data quality entered will result in poor quality outputs.
The implications could be wide ranging. For example:
- Reputational harm with customers due to mistakes
- Low user trust and adoption
- Time intensive checks to ensure contracts are correct
In short, validation rules can be a useful tool to improve data integrity. This then helps with any other outputs generated from the data (e.g. documents, reports, dashboards, or informing decision making etc).
How to create validation rules
The core process of creating a validation rule is simple. Follow these steps.
Examples of validation rules
Validation Rules can be used in various ways. If you need some ideas or inspiration, check out this article from Salesforce Help & Training. This provides many examples for various use cases. You’ll almost certainly find something which can be easily tweaked to suit your needs!
Tips for your validation rules (do’s and don’ts)
Here are some tips for using Validation Rules in your org:
- Do: Think before you start. Understand the need and your logic carefully. Consult users and consider both direct and indirect impacts of your rule (see below).
- Do: Keep your logic as simple as possible. There is no need to overcomplicate a validation rule!
- Do: Use the Description field or document the rule. Business needs change over time. You, or someone else will probably need to know why a rule was created in the future!
- Do: Test rules carefully and consider their impact on existing data and processes. For example, a new rule could impact existing records, and processes such as web-to-lead, web-to-case, and integrations.
- Do: Re-evaluate rules with your team. Understand if they are helping or need adjusting.
- Do: Consider creating a ‘switch’ to help turn validation rules on/off in bulk to help with administrative activities (e.g. data loading). An example is available here. Alternatively, consider using tools such as the ‘Switch’ Heroku App (here).
- Don’t: Vague errors will confuse users, hurt adoption, and probably increase your support workload! Create clear error messages.
- Don’t: Overuse validation rules. Each object has limits (click here). Too many validation rules will likely be a poor user experience. Use the appropriate tool for your challenge (e.g. settings on the Page Layout, screen flows to guide users, exception reporting, etc).
- Don’t: Try to use validation rules to stop record deletions. Consider alternatives, such as object access rights or an Apex Trigger. An example of the latter is available here.
Lastly, remember that Validation Rules are only one of the tools available to help with maintaining data quality. Choose the right tool to address the need. We’ll be exploring other tools in future posts!
Validation Rules are one of the tools available to help with data management in Salesforce. They can have many use cases. Carefully consider their usage, alongside the other tools available, to maintain high quality data within your Salesforce org.
Bonus Penguin Fact
Young Penguins are known to be curious. Sanyika the 6-month-old African Penguin from Budapest Zoo recently decided to go for an adventure around the city centre. Learn more about Sanyika’s sightseeing trip here!
Found this article useful? Why not share!
Or check out some of our other articles: