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
SF Beginner 2019SF Beginner 2019 

assigning permission set on newly created partner user

How do I assign a permission set on  newly created partner user?
 
public class AssignPermissionSet {
    
    public static void assignperm(List<user> userlist){
        Set<ID> usersId = new Set<Id>();
        Set<Id> contactIdsSet = new Set<Id>();
        List<PermissionSetAssignment> permissionSetList = new List<PermissionSetAssignment>();
        
        
        for (User u : [Select Id, Name, ProfileId FROM User Where Id IN : userlist]){ // Add fields as per your requirement...
            if(u.ProfileId == '00e360003429432'){
            PermissionSetAssignment psa = new PermissionSetAssignment (PermissionSetId = '0PS33609skjojsae', AssigneeId = u.Id);
            permissionSetList.add(psa);
                }
        }
        insert permissionSetList;
    }
}

 
Best Answer chosen by SF Beginner 2019
Karthikeyan Rajendran 14Karthikeyan Rajendran 14
Hi SF beginner

      I assume that you are facing a problem in assigning permission set to Partner user.

While creating Permisison Set you will be selecting the type of users using the permission set. License will be selected from the drop down. Check whether your permissionSetId = '0PS33609skjojsae' has any license assigned to it. If yes then only those users can use the permisison set.

If you want every user irrespective of the license then choose none.

Please check the following post for reference
https://success.salesforce.com/answers?id=9063A0000019RJgQAM

Regards
Karthik

All Answers

Karthikeyan Rajendran 14Karthikeyan Rajendran 14
Hi SF beginner

      I assume that you are facing a problem in assigning permission set to Partner user.

While creating Permisison Set you will be selecting the type of users using the permission set. License will be selected from the drop down. Check whether your permissionSetId = '0PS33609skjojsae' has any license assigned to it. If yes then only those users can use the permisison set.

If you want every user irrespective of the license then choose none.

Please check the following post for reference
https://success.salesforce.com/answers?id=9063A0000019RJgQAM

Regards
Karthik
This was selected as the best answer
SF Beginner 2019SF Beginner 2019
for example I have a field in user and I want to set it to true, how can I add that?