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:
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.....