Validation Rules in Salesforce verify that the data entered by a user meets certain criteria before the user can save the record. The beauty of Salesforce is that business logic can be applied relatively easily and it takes no time at all to create a validation rule.
However, you need to consider the downstream impact this seemingly innocent configuration could have. This short guide explains what to do once you’ve created a validation rule. I’ve learned this the hard way, so I hope that armed with this information, you won’t fall into the traps either.
Update Existing Records
Once you’ve enforced a validation rule, it’s highly probable that existing records won’t meet the rules’ criteria. Of course, as users work with records, they will tidy up cumulatively.
Where this becomes a bugbear, you need to:
- Perform a mass import/upsert.
- Have integrated platforms passing data into Salesforce.
In terms of imports/upserts, read about the errors you can encounter in the guide below:
One example of when this happens with an integrated platform is Account Engagement (formerly Pardot). You may believe that as a Salesforce product, you’re safe. However, the connector between Account Engagement and Salesforce exists because the two are not entirely using a single database. A common connector sync error is the result of a validation rule on the Salesforce side rejecting the incoming data from Account Engagement records that don’t meet the validation rule’s criteria.
You should consider a mass update of records using an import tool to prevent this from happening so that record data is aligned with validation rule requirements. You will need to pull a report containing the affected records, do an export, and manipulate the data before reimporting it.
Of course, only change data that makes sense, and make sure that you’re not touching any records where the accurate answer can’t be determined by you.
Don’t Disrupt the Flow of Work
As mentioned, once you’ve enforced a validation rule, as users work with records, they will tidy up incrementally. However, if you haven’t taken steps to mass update record data, then users will bump into validation errors more frequently.
- Error messages: Make validation rule error messages clear so it can explain what needs to be changed before the record can be saved. When creating validation rules that relate to specific field/fields in the same page section, select the Field Error Location option (also consider this for long record pages). If the rule relates to multiple fields that could be positioned in multiple sections, it’s best to opt for the Top of Page Error Location.
- Fields on page layouts: Ensure that any fields included in the validation rule are added to Page Layouts. In cases where you may have multiple page layouts for different users (e.g. by team), checking this is essential especially if the set of users hasn’t needed to work with the field until now. Also, check Dynamic Forms, as the visibility of these fields can override the baseline page layout.
- Reports and list views: Update the columns on these so that users don’t get stuck when using inline editing. It can be irritating to update multiple records only to be faced with multiple errors, and then have to click into each record one by one to remedy the data discrepancies.
While it takes no time at all to create a validation rule, you need to think about the downstream impact this seemingly innocent configuration could have.
Aside from properly testing the rule, walk through how it could impact existing records. Nip any problems in the bud by re-importing ‘known’ data to meet validation rules requirements. Following that, put yourself in your users’ shoes to update the user interface (page layouts, dynamic forms, reports, and list views).
Armed with this information, you hopefully won’t fall too hard into these traps.