Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Salesforce by (11.9k points)

Usually, when a trigger runs, we check what kind of a profile the user has, and if it's the kind where we don't want the triggers to run, then we exit the trigger before running any other code.

Problem: we have a SF package installed that we purchased from some other company, and all of its code is invisible to us, and is not editable. How can we stop some of those triggers from running other than manually disabling them through UI? I want to temporarily disable them while running a test class.

Was thinking about doing something like this, but got an error saying "DML not allowed on ApexTrigger."

ApexTrigger at = [select id from ApexTrigger where name='SomeTriggerName'];

at.status = 'Inactive';

update at;

1 Answer

0 votes
by (32.1k points)

I don't think that there's a way to do what you're asking without having the owner of the executed package update the Apex Code.

The suggestion you listed before the problem is a great one; I would recommend using Custom Settings in addition, though. You could support the owner/developer of the Trigger to implement a Custom Settings check before executing the Trigger(s). That's the best solution I could have come up with for some of my own Triggers.

It would be great if the ApexTrigger object could be updated, but Salesforce doesn't allow it.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...