1

I want to run one script on my custom object say obj__c which will update 1 field of this object. This object obj__c is having a trigger on update which I don't want to run when my script runs.

4
  • 2
    I do not believe it is possible. You could contact the vendor and see if they would add the ability to do so.
    – Eric
    Nov 27, 2015 at 18:03
  • I am agree with @Eric.
    – Ratan Paul
    Nov 27, 2015 at 18:11
  • If I am creating that package, is there any way I can do something while creating package Nov 27, 2015 at 18:17
  • See Keith's answer below
    – Eric
    Nov 27, 2015 at 19:06

1 Answer 1

3

If you are using a trigger framework the ability to disable triggers should be part of that.

If not, then a simple approach is to start every trigger with this line:

trigger MyTrigger on Obj__c (after update) {
    if (Triggers.areDisabled) return;
    ...
}

that makes use of this static field initialised from a public (so can still be modified when the package has been installed) custom setting:

public class Triggers {
    public static Boolean areDisabled {
        get {
            if (areDisabled == null) {
                areDisabled = Settings__c.getInstance().DisableTriggers__c;
                if (areDisabled == null) areDisabled = false;
            } 
            return areDisabled;
        }
        set;
    }
}

This allows all the managed package triggers to be turned on and off via that custom setting.

Not the answer you're looking for? Browse other questions tagged .