The easiest way is to use UserInfo.getName() method.
If (UserInfo.getName() != 'Some User Name') {
// Do processing here
}
I would recommend to have this implemented by profile instead
If (UserInfo.getProfileId() != 'Certain Profile ID') {
// Do processing here
}
But if you want to have support for multiple users, you should use a map or a set to make this more maintainable.
Set<ID> bannedIds = new Set<ID>();
bannedIds.add('ID1');
bannedIds.add('ID2'); // add more ids to ban
if ( ! bannedIds.contains(UserProfile.getProfileId()) ) {
// do processing here
}
The easiest way is to use UserInfo.getName() method.
If (UserInfo.getName() != 'Some User Name') {
// Do processing here
}
I would recommend to have this implemented by profile instead
If (UserInfo.getProfileId() != 'Certain Profile ID') {
// Do processing here
}
But if you want to have support for multiple users, you should use a map or a set to make this more maintainable.
Set<ID> bannedIds = new Set<ID>();
bannedIds.add('ID1');
bannedIds.add('ID2'); // add more ids to ban
if ( ! bannedIds.contains(UserProfile.getProfileId()) ) {
// do processing here
}
Step 1 : - create a new custom filed on the user object. ( Bypass_Trigger__c) Data type is checkbox ..
If this checkbox is checked to any user the trigger wnt execute to the user ...
// Query the salesforce current logged in user
User u=[Select Bypass_Trigger__c
from User
where id=:UserInfo.getUserId()] ;
// Check if the current user is allowed to bypass the trigger
if(!u.Bypass_Trigger__c){
// YOUR Loggic
}
I would recommend to have this implemented by profile instead
But if you want to have support for multiple users, you should use a map or a set to make this more maintainable.
All Answers
I would recommend to have this implemented by profile instead
But if you want to have support for multiple users, you should use a map or a set to make this more maintainable.
Step 1 : - create a new custom filed on the user object. ( Bypass_Trigger__c) Data type is checkbox ..
If this checkbox is checked to any user the trigger wnt execute to the user ...