You need to sign in to do that
Don't have an account?

UserId to be excluded from trigger
If((LeadList[0].OwnerId != '005User1') || (LeadList[0].OwnerId != '005User2) || (LeadList[0].OwnerId != '005User3'))
Need help writing this line better
You need to sign in to do that
Don't have an account?
If((LeadList[0].OwnerId != '005User1') || (LeadList[0].OwnerId != '005User2) || (LeadList[0].OwnerId != '005User3'))
try this code
Direct comparing with id is not a good paractice. While you deploy in different org/production, you will not found those Id and you trigger will not work.
You can do in following way:
1: @Raj V mentioned here.
2: Do soql on USER object and put WHERE condition accordingly to get relavent users only. Like:
Map<Id,User> mapUsers = new Map<Id, User>([Select Id, Name, ProfileId, Profile.Name From User Where Name Like '%Test%']); //Any other filter
If(mapUsers.containsKey(LeadList[0].OwnerId)) {
//Your Logic
}
3: Create custom setting / Label, Keep all Ids there and fetch into trigger code in a Set variable Like that:
//Taking custome label: UserIds .
// Keep id with comma seperated. u001,u002....
//YOu can deploy and update according to differnt orgs.
String uIds = Label.UserIds;
Set<String> userIdsSet = new Set<String>();
if(!String.isBlank(uIds)) {
List<String> userIds = uIds.split(',');
userIdsSet.addAll(userIds);
}
if(!userIdsSet.contains(LeadList[0].OwnerId)){
//YOur logic
}
Might be it will help you !!
Thanks
Niraj
I tried what Raj suggested and am getting this error