Let’s make some magic…
Throughout my time using Salesforce.com, I’ve been lucky enough to have tons of opportunities to network with other customers. One of the many patterns that starts to emerge is from new customers who are struggling to find a starting point. They hear others talking about all the cool & fun stuff they are doing, but have no idea how to have that ‘magic’ in their org.
Now, there are a lot of places to start, but one in particular has a “oooooo” factor in my opinion that gives it a real ‘magic’ feel – validation rules! These nifty little things hold a special place in my heart because they were the subject of the presentation I did the first time I was asked to speak at Dreamforce. (If you want to see that, it’s here – and I sound so totally terrified. How embarrassing!) The great thing about validation rules is that they are fairly simple to set up, have that wow-factor & most importantly, it touches on one of the biggest problems that all databases experience – data quality!
One of my most dreaded projects was when we did territory alignment, but our address data was so messy. My first venture into validation rules took a stab at cleaning that up. Here are some of the first validation rules that I created way back when…
Short & sweet, but it prevents people from marking deals as won with a closed date in the future. (Conversely, if you wanted to prevent people from marking closed won deals in the past, all you need to do is flip the > sign.):
AND((ISPICKVAL(StageName, "Closed Won") ),(CloseDate > TODAY() ))
Another simple one that was a huge win for us was the first step in rolling out approval processes. We had a roll-up summary field that calculated the maximum product discount. If that was over the allowable amount for our sales reps (10%), a checkbox that was only editable by managers must be checked. It was a very simple solution to a complex problem, but it was our first step in the right direction.
AND(Discount_Max__c > .1),(Approved__c = False))
One word of caution – validation rules make data loads & fast testing a pain in the butt. I found this out as we started heavily using them, and I asked Salesforce for a bit of assistance fixing this issue. I understand why my idea is problematic, so I came up with a solution on my own. SAFE HARBOR – use this at your own risk!
I added a field to the User record that is only editable by Sys Admins, called Exempt from V Rules. Then I appended all of my validation rules with the following:
$User.Exempt_from_V_Rules__c = False
Obviously these are a very small sampling of validation rules. A majority of the time, these are something really simple that have big wins. Since these first initial rules, the validation rules I’ve written have gotten more complex, and I always have to be aware that end users will search for ways to game the system, but they are a really great tool in the fight against bad data.
Special thanks to Michael for help with the formatting of this post!