You need to sign in to do that
Don't have an account?

Hii Everyone!! I have to deactivate an trigger which is currently running without deleting it. Anyone help me to solve this.
trigger UpdateStage on Account (after insert, after update) List<Id> accountId = new List<Id>(); for(Account acc : Trigger.new) { if(acc.All_Opportunities_Won__c==True) accountId.add(acc.Id); } List<Opportunity> oppsToUpdate = new List<Opportunity>(); for(Opportunity opp : [select id, StageName, Amount from Opportunity where AccountId in: accountId AND Amount != 0]) { opp.StageName='Closed-Won'; oppsToUpdate.add(opp); } update oppsToUpdate; }
This is my apex Trigger. how to deactivate this?
you can simple mark the trigger inactive, please refer the screen shot attached.
In case it is in production, you need to follow the proper channel as marking the trigger inactive in sandbox/Developer org and migrate it to production using changesets. This link provides more insight
https://help.salesforce.com/articleView?id=000005417&type=1
If you still have doubts, feel free to ask else if this helps, please mark the solution as green.
Cheers, Dev
All Answers
You can refer below discussion related to same thread
https://developer.salesforce.com/forums/?id=906F0000000MJM9IAO
Thanks
Arpit
you can simple mark the trigger inactive, please refer the screen shot attached.
In case it is in production, you need to follow the proper channel as marking the trigger inactive in sandbox/Developer org and migrate it to production using changesets. This link provides more insight
https://help.salesforce.com/articleView?id=000005417&type=1
If you still have doubts, feel free to ask else if this helps, please mark the solution as green.
Cheers, Dev
1. Creating the custom setting,
2. Modify your trigger to check the custom setting value
Set your logic based on the custom setting value. For example: if your custom setting MyCustomSettingsObject.TriggerStatus__c' value is set, and then, execute the trigger logic else skip everything.
if(MyCustomSettingsObject.TriggerStatus__c== true){ <your code>};
If you still have doubts, feel free to ask else please mark the solution as green.
Cheers, Dev
I dont know how to use this!!
Please see below sample code. May be this could help you to understand the complete flow related to trigger, class, custom setting.
//Your Trigger Code
trigger UpdateStage on Account (after insert, after update){
Suppose you are having one custom setting then below will be the code to on/off your trigger logic
TriggerSupport__c support = TriggerSupport__c.getAll();
Boolean isOff = support.get('Account').TriggerOff__c;
if(! isOff) // Trigger will only execute when TriggerOff__c field is not checked in custom setting 'Account' record.
{
UpdateStageHelper.AfterInsert(trigger.New);
}
}
// Your trigger handler class
public class UpdateStageHelper(){
public static void AfterInsert(list<Account> triggerNew){
// Your Logic...
}
}
Let me know for any further question or concens.
Please let us know if this helps !!
Thanks
Arpit