+ Start a Discussion
fourfourfunfourfourfun 

"Who" do Apex triggers run as?

Just curious. I just slapped in a clause in validation to bypass all the rules, essentialy to let bulk data updates by system admins to change records whether or not there are rules there.

How would this apply for Apex triggers? What would they run as? The code creator? I'd love to put a piece of code into Salesforce but I don't want to get spammed by errors when I do bulk updates that trigger it.
Best Answer chosen by fourfourfun
Vinit_KumarVinit_Kumar
I am afraid you won't be able to bypass validation rules coz the validation rules are re-evaluated after your Trigger has performed the action.

The only workaround I can think of is to have a checkbox field and set it to true and bypass your validation rule if this value is True and run your Trigger.

Hopw this helps !!

All Answers

Vinit_KumarVinit_Kumar
Apex Triggers runs in System context not in User's context ..

Hope this helps !!

fourfourfunfourfourfun
Shame. Is there a system ID equivalent you reckon I could put in validation to make a trigger bypass it?
Vinit_KumarVinit_Kumar
I am afraid you won't be able to bypass validation rules coz the validation rules are re-evaluated after your Trigger has performed the action.

The only workaround I can think of is to have a checkbox field and set it to true and bypass your validation rule if this value is True and run your Trigger.

Hopw this helps !!

This was selected as the best answer