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

Update User preferences for specific profile on user Creation
Hi,
I am trying to create a trigger when Users are created with a specific custom profile(there are multiple), they need to have the service cloud user flag checked. The trigger for enabling the flag on user creation was easy enough, but how do I limit to specific profiles? Is this possible?
trigger ForceServiceCloud on User (before insert) {
for (User userInLoop : Trigger.new) {
userInLoop.UserPermissionsSupportUser = true;
}
}
I am trying to create a trigger when Users are created with a specific custom profile(there are multiple), they need to have the service cloud user flag checked. The trigger for enabling the flag on user creation was easy enough, but how do I limit to specific profiles? Is this possible?
trigger ForceServiceCloud on User (before insert) {
for (User userInLoop : Trigger.new) {
userInLoop.UserPermissionsSupportUser = true;
}
}
trigger ForceServiceCloud on User (before insert) {
List<User> userList=[Select id, user.profile.name from user where id in : Trigger.new];
Set<String> profilelist=new Set<String>();
//Add profile name
profilelist.add('p1');
profilelist.add('p2');
for (User userInLoop : userList) {
if(profilelist.contains(userInLoop.profile.name))
userInLoop.UserPermissionsSupportUser = true;
}
}
now on code use set<string> prfs = label.xyz.split(';');
then check for profile name from set. this way when you want to add or remove new profile, you can simply modify label than code.