You need to sign in to do that
Don't have an account?
The new Learner
How to stop the triggers not to fire for any profile using custom setting
Hi Experts,
Can anyone help me how out, how to the stop the triggers not to fire any profile using custom setting. Thanks in advance
Can anyone help me how out, how to the stop the triggers not to fire any profile using custom setting. Thanks in advance
You can create hierarchy custom setting and create "isProfile" checkbox custom field and set it's value as false and then use that check in your apex trigger before caling any method to perform certain actions.
Thanks
Greetings to you!
Make use of custom setting using which you can control whether a trigger should run or not. Create a custom setting (say Trigger_Settings__c). Add a checkbox field “Is Active”. So your custom settings will store the trigger name and its status in IsActive checkbox.
Then in your apex trigger, add an IF condition at the top to check if the Trigger status in Custom settings is TRUE, only then run the entire apex trigger code.
So, every time you want to turn off the trigger in production, just go to your custom settings and uncheck the IsActive checkbox for that trigger.
Please refer to the below links which might help you further with the above requirement.
https://riptutorial.com/salesforce/example/17388/using-hierarchy-custom-settings-to-disable-apex-code
https://jkilburn2043.wordpress.com/2015/10/06/turn-triggers-on-and-off-with-custom-settings/
https://salesforce.stackexchange.com/questions/166252/activate-and-deactivate-trigger-using-custom-setting
https://sfdcfanboy.com/2017/11/23/a-tip-a-day-23-5-ways-to-stop-trigger-in-production/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
I have created custom setting like below, how can i get to know that whether this code working for all the profiles or not and also for specific user as well. Kindly help me.
Application__c bypassTrigger= Application__c.getInstance( UserInfo.getProfileId() );
if(!bypassTrigger.DisableTrigger__c){
Create a Checkbox field on the User Bypass_Trigger__c
if you set this value to true you can bypass the trigger like below
Application__c bypassTrigger= Application__c.getInstance( UserInfo.getProfileId() );
if(!bypassTrigger.DisableTrigger__c){
System.debug('Trigger is firing');
}
You can login with different users having different profiles and identify if the trigger is firing or not by adding System.debug('Trigger is firing') in your code.
Thanks