Assigning permission set to user in apex

Is it possible to assign permission setting using code? Are there any limitations to consider?

YES, it’s possible as below:

PermissionSetAssignment psa = new PermissionSetAssignment (PermissionSetId = myPermissionSetId, AssigneeId = UserId);
insert psa;  

1 thought on “Assigning permission set to user in apex”

  1. Pingback: How to add Apex Class Access to permission set programmatically – SFDCian

Comments are closed.