Bypassing Data Validation, the Clever Way

Q: “How do I make a Salesforce record bypass Data Validation?”

A: The Clever Way:

  1. create a checkbox field on the desired object called “Toggle Me to Bypass Validation” (or something like it); and
  2. change your Validation Rules on the desired object to ignore records where “Toggle Me to Bypass Validation” has changed–add a clause like NOT(ISCHANGED(Toggle_Me_to_Bypass_Validation__c)).

You’re done!


In the pastfolks implemented this the Adequate Way:

  1. create a checkbox called “Bypass Validation Rules for this Record” (or something like it);
  2. change your Validation Rules to ignore records where “Bypass Data Validation for this Record” is TRUE–add a clause like NOT(Bypass_Validation_Rules_for_this_Record__c); and
  3. create a Flow or Apex Trigger to change “Bypass Data Validation for this Record” back to FALSE whenever it’s set to TRUE.

The problem with this approach: step 3.

  • The Flow or Apex Trigger changes the record AGAIN, which–depending on your config–could cause logic to re-run. suboptimal.
  • The Clever Way only touches the record once.
  • If you need to programmatically bypass Validation Rules for an existing record, set the record’s “Toggle Me to Bypass Validation” to NOT(Toggle_Me_to_Bypass_Validation__c) in your Flow or Apex logic.

Props to Hanna Martynenko for the idea!

Leave a comment