You need to sign in to do that
Don't have an account?
djain
Disable Apex Trigger
Hi,
In my application i need to disable the trigger while importing data in Contact ,
and to disable the Trigger the sample code is
Code:
private void enableDisableTrigger(String triggerName,Boolean isActive){ ApexTrigger tr=[Select a.Id from ApexTrigger a where a.Name=:triggerName limit 1]; if(tr!=null){ tr.IsValid=isActive; update tr; } }
but in this case i get an error: DML not allowed on ApexTrigger
Please guide me.
Thanks in advance
You have 2 workarounds that I am aware of.
1) update your trigger to be bulk safe, and allow it to fire on your records as they are imported. This is probably the best option, if you can figure out how to do it.
2) update your trigger to test for certain bulk conditions, such as the running user being an admin and when the Trigger.new.size() > xxx records. when these are not true, execute the trigger code, otherwise, drop out.