Thursday, May 16, 2019

Activate/Deactive Trigger method using configuration


During development ,we often come across a scenario where we need to activate/deactivate certain method of apex trigger/classes.To do this we can make good use of custom setting.

Step 1:Create custom setting:


Step 2:Create custom setting Record:


We have created custom setting with name Trigger Deactivation in step 1 and in step 2 we have created custom setting record with SendAccountUsingRestApi because we want to acivate/deactivate this method.

Use below code snippet to achieve this:

We have check value of  SendAccountUsingRestApi  custom setting's is Method active field on line no.7.When this flag is active,method is get called otherwise this logic is equivalent to commented out.


You can see below debug logs in two different scenario:

  • When Is Method Active is True

  • When Is Method Active is False





No comments:

Post a Comment

Please leave your comment.....