For Example I have a validation rule in Opportunity Object, that we should not leave the type Field as blank. Below is the screen shot for that.
Validation rule for above message look like below.
I want to see the error message in the UI and not on trigger. If I want to update the record via trigger, I should not see this error message.To overcome this, sometimes we want to bypass the validation rule.
To avoid validation rule for particular profile, we can give the validation rule like below.
we want to by pass validation rule when any Profile user attempt to execute the trigger, we can follow the below steps.
1. Create a check box field in Opportunity Object, say "By Pass Validation"
2. we need to change the validation rule like below.
3.When I change the subject of task it should update the Opportunity, Task trigger will look like below. In that trigger I have updated the opportunity field "By Pass Validation".
4. We need to create the workflow, because we have made the By Pass Validation field to true, which will always skip the validation. We want the validation to skip only the trigger.
Once the workflow is activated, It will skip the validation rule for the trigger not from UI.