Find your content:

Search form

You are here

How to bypass Validation logic in a Trigger


If I have a trigger that works fine (generally), but which is generating false results due to VALIDATION RULES, how can I tell the trigger to ignore Validation rules (if at all)?


Trigger checks how many OTHER leads have the same email address, adds a marker to the current lead if it finds any at all.

I have validation rules (such as REQUIRING a field "Country_List__c" to be populated) which can be bypassed by, let's say, web-to-lead insertion, but which my trigger is not generating an ERROR FOR but it's falsely pulling a TRUE when checking for OTHER LEADS with the same email address.

I deduced this by editing and saving one of the problem records directly in SF GUI. It ran the trigger fine BECAUSE two Validation rules were handled (I forced fake phone number and I forced a country into Country List).

I'd like the trigger to IGNORE validation rules. Is this possible?

Attribution to: AMM

Possible Suggestion/Solution #1

You cannot make the trigger ignore validation rule failures, however you can add exclusions to the Validation Rule.

If you use Lead Source as 'Web to Lead' for Leads that are created via that channel, you could add an exclusion to the Validation Rule

You could add this to the Validation rules that you want to skip

NOT(AND( ISPICKVAL(LeadSource, 'Web to Lead'), ISNEW() ))

Attribution to: techtrekker

Possible Suggestion/Solution #2

It is not possible for triggers to ignore validation rules without adding custom logic.

If the request to save a record originates outside of a Standard UI edit page, any before triggers you've defined will run prior to the execution of validation rules.

Unfortunately, once all the before triggers are finished, Salesforce will run, without exception, the System validation rules (ie. required fields, max length, etc.) and User-Defined validation rules (ie. the formula-based rules you've defined).

Here is one strategy to bypass this behavior:

  1. Add a "Skip Validation" Checkbox field to the object
  2. Set the "Skip Validation" field to TRUE in a before trigger.
  3. Add logic to your validation rules so that they do not execute if "Skip Validation" is set to TRUE.

Attribution to: Mohith Shrivastava

Possible Suggestion/Solution #3

I handle this by specifying the user name of the process in the trigger and then use logic in the Validation rule that exempts that user

Attribution to: user2671
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content