I have a picklist field on opportunity, which contains some values for example: A, B, C, D

The user must be able to update A or C during record edit if he tries to edit values other than A and C validation rule fires. But when trigger fires it should be able to update any of the values validation rule should not be fired.

I tried creating one flag on opportunity but this method will allow both system and user to edit the field.

So please provide any suggestions on this??

  • You can stop users from modifying the flag on opportunity by making the field not visible using profile field level security or removing the field from the opportunity layout. – Keith C Jul 16 '14 at 16:25
  • So, the trigger will be invoked via use cases other than user input - such as data loader or API? And in those cases, the VR should not execute but if user entry, the VR should execute? – cropredy Jul 16 '14 at 16:49

You can use a custom setting in the validation rule and change its value in the trigger, so that the validation rule does only fire during a user interaction. The idea is described here: Make Validation Rule bypass if TRIGGER is run?

Be aware that in a Salesforce org with a lot of traffic, this pattern could lead to sporadic locks on the custom setting.


Create checkbox field on object which have validation rule, change value of that field whenever you want to bypass validation rule, it may be from Apex class or trigger or process builder. In validation rule put And condition as below :- AND(!ISCHANGE(created_field),(Your original condition))

Your Answer

