You need to sign in to do that
Don't have an account?
iswarya sekar 7
hello everyone !! I need to deactivate a trigger using custom setting without altering the trigger code. Can anyone help me in this? Thanks in Advance !!
trigger UpdateStage on Account (after insert, after update) { // Performs Custom actions after Record gets saved. List<Id> accountId = new List<Id>(); // get the list of all Account's ID to be Updated. for(Account acc : Trigger.new) { if(acc.All_Opportunities_Won__c==True) // Checks if the Condition is 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]) // used to get all records from above ID. { opp.StageName='Closed-Won'; //Update StageName in Opportunity oppsToUpdate.add(opp); } update oppsToUpdate; // Update all Opportunity in List. }
Select check Unchecked to activate trigger again.
All Answers
Please check once below sample code : More info for creating custom settings and all please check once below link:
http://salesforceprasad.blogspot.sg/2017/01/how-to-disableenable-all-validation.html
I hope it helps you.
Please let me know in case of any other assistance.
Thanks
Varaprasad
You can not deactivate the trigger through custom setting but you can customize the trigger on the basis of custom setting value.
After creating the custom setting, you will need to modify your trigger to look up the custom setting value and skip all of your trigger logic if the value is set.
Thanks
Mukesh Kumar
For example, If we are create a checkbox field, when it is true it will activate the trigger, when false it will deactive it. Can this will happen using Custom Settings? i don't know. Just asking you some suggestions!! Help me!!
No, it is not possible without using custom settings data in the trigger.
Thanks
Varaprasad
Make field to IsActive__c false on custom settings.
Select check Unchecked to activate trigger again.
I Unchecked it. But the trigger is in inactive mode. Its not working for me.. What i did wrong?
Please follow :-
please MARK AS BEST ANSWER!!!!
Regards
Mukesh