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
matthew Gordonmatthew Gordon 

Update User preferences for specific profile on user Creation


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 : {
        userInLoop.UserPermissionsSupportUser = true;
Please try this

trigger ForceServiceCloud on User (before insert) {
List<User> userList=[Select id, from user where id in :];
Set<String> profilelist=new  Set<String>();
//Add profile name
    for (User userInLoop : userList) {
            userInLoop.UserPermissionsSupportUser = true;

Add list of profiles to custom label like p1;p2;p3 etc.
now on code use set<string> prfs =';');

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.