Validation Rules: Why Should I Use Them?

NEW from the Tether Tips Blog – Validation Rules: Why Should I Use Them? 

A really helpful tip from our Salesforce Administrator Simon O Leary this week.

Introduction:

Validation rules are an incredible tool for controlling data entry in your Salesforce Org. Using these, you can restrict values users can enter and ensure they enter the necessary fields when they are supposed to. This can improve reporting, ensure vital details are not missed and increase internal response times as information is more readily available.  

In this post, I will run through an example of validation rules to demonstrate how an admin can look to implement them in their system.  

Imagine the scenario you are creating a new account for a company and, if it’s a banking company, need to know how it is owned (Public, Private, etc). For this we could make both fields required on the page, but then the ownership field would need to be populated for every account, rather than just banks.  

While this sounds specific, you can change this to fit the following format: 

If X is this value, Y has to be filled in 

Once you consider it this way, it is a lot more applicable to your average org.  

To implement this, go to Setup -> Object Manager -> Account and find the Validation Rules tab on the left: 

From here click “New” and enter your rule name.  

The next part is where most people are dissuaded: you’ve got to create a formula. The way I start is inserting the fields I will need, so in this case they are “Industry” & “Ownership”.  

Now you need to fill in the Salesforce functions which check if these are filled or not. Both of the fields we are working with here are picklists so the first functions will be ISPICKVAL()  around both our fields. This will check the current value in the field (Like asking the system ‘What is the picklist value’) 

Next we need to put in our values to be checked, in this case “Banking” and empty, which can be shown by “ ”.  

So, with the logic in place, we just need to fit this into the Salesforce Validation Rules format. This means we need whatever is in this box to equal TRUE/FALSE. To do this we will be using the AND() function. 

AND() takes two statements and, if they are both true, it returns “True” otherwise (If either is false) it returns “False”.  

If there’s multiple values that require another field to be input, you can start adding in OR() or CASE() statements but we’ll get to those in a another Tether Tip.   

Validation Rules can sometimes take a bit of trial and error (And counting how many brackets you’ve used over and over as you continually doubt your ability to count to five) but if go through step by step you will get there in the end!

And with that we have a working validation rule! You can enter your error text below in the box and save your formula.   

Figure 5 – its rare im happy to get an error

Over time you can add more to these rules or just add new ones and really customise an org down to the small details. As I said, this is a specific example that can be catered for your business as now, in this example, when someone pulls a report of all accounts in the banking industry, we know the necessary information will be there. 

Thanks for reading, We hope this has helped.

The Tether Team

#salesforce #salesforcecrm #tethertips #crm

Share the Post: