function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
katriragkatrirag 

HOW TO PREVENT TRIGGER THAT SHOULD NOT RUN ON PARTICULAR USER

It is possible to prevent the trigger that should run on particular users? How can we achieve this.

Thank you
 
Abhishek BansalAbhishek Bansal
Hi Katrirag,

The trigger will be called for each and every user, there is no way to stop it from triggering for particular users but however you can contol the execution of the code that is written inside the trigger. You can add a check at the starting of the trigger so that it will execute only for the particular set of users. Sample code is given below:
trigger testTrigger on Contact(before insert, before update) {
	if(LoggedInUser.Name == 'xyz'){
		//Execute this code
	}
}

In this way the above trigger code will be executed only for the User whose name is xyz. Please let me know if you need any further information on this.

Thanks,
Abhishek Bansal.