0

I have a before insert/update validation trigger which I would like to be able to ignore when doing mass updates via data loader. Figured if I just add criteria of "checkbox field = true, ignore validation", but doesn't seem to work since it's a before trigger, and I'm making that value true during the update.

Is there any way to accomplish this?

4

I recommend you use Custom Permissions to control these validation rules. You can use the $Permission global variable to add a criterion like the following to each:

$Permission.ByPassMySpecificValidation

Make sure you come up with a clear, specific name so that this solution will scale. You can then add this Custom Permission to a Permission Set (I usually use the same name if it controls just this one Custom Permisssion). Assign yourself to this permission set before running your data load, then remove the assignment when you are done.

  • remembering to remove the assignment in today's multi-tasking world is the hard part – cropredy Dec 6 '18 at 22:38
  • You could build out a framework for temporary assignment if that's a major worry. It wouldn't be a ton of work, but not trivial either. – Adrian Larson Dec 6 '18 at 23:20
  • in our org, we use a special user 'Data Migration User' and if there are validation rules that should be excluded for data migration, they are coded as such (using hierarchical custom settings). It is easier to remember to use the special user for data migration than to (un)assign a permission to the running user - plus, you get an audit trail on changed fields associated with the 'task' of 'data migrating' – cropredy Dec 7 '18 at 0:49
  • You can adopt the separate user approach whether you use hierarchy setting or custom permission. – Adrian Larson Dec 7 '18 at 1:10
  • An ideal marriage ! – cropredy Dec 7 '18 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.