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!


6 Responses to “Let’s make some magic…”

  1. The Exempt from V Rules idea is interesting. We attack the problem at the profile level by building those exceptions into the rules themselves. Less management at the user level (with albeit less granular control.)

    • Yes, we purposefully wanted it to be more granular. It’s a pretty powerful little checkbox & we wanted tight control on it. (Technically, any sys admin could have changed it for themselves, but only myself & one other person knew the field existed. Still, slightly troubling…)

  2. Love the Exempt from V Rules idea. Ideal since you could even have a practice to leave it off for everyone in day-to-day operations and turn it on only for bulk uploads, etc. when someone with authority turns it on for a limited period of time. Could even place more button-click-admin stuff in there to ensure it is automatically turned off after a time period. Could even …. Gave me lots to think about. Thanks!

  3. In thinking more about the Exempt from V Rules idea I have to say… I love it! Huge win for Apex developers who can now write unit tests without worrying about validation rules in their test data. Especially nice for all those pesky AppExchange unit tests that don’t know anything about your validation rules. Just turn off rules for the person doing the deployment and away you go. Fantastic idea Becka! This is one of those things I’m going to add to my “list of stuff to do in every org I work with.”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: