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
Proposal ButtonProposal Button 

Question on Trigger

Hi All
 
I have a particular question in trigger
 
I wrote a trigger After insert and After update. It effects to all the users but, it i want to reflect to a particular user for eg BA User (User name) . If this user updates or Insert any records i don't want to fire a trigger. So can you please hep me out with the Syntax
 

David81David81

The easiest way to do it is to just wrap the body of your trigger code in an if statement and check the current user's username with UserInfo.getUserName()

granigrani

The recommended way would be to use hierarchical custom settings. Create a custom settings of type hierarchy. Add a checkbox type field (do_not_fire_trigger) to the custom settings object. Set it to true for the specific user you do not want the trigger to fire. In your trigger get the value of the custom settings checkbox field by passing the logged in user id

Custom_setting__c c = Custom_setting__c.getInstance(UserInfo.getUserId());

if (c != null && !c.do_not_fire_trigger__c) {

       //execute your trigger logic...

}

 

hope this helps.