[SalesForce] Automated Permission Set Group Assignment

For our user provisioning (from AD) I want to automate the permission set groups that are assigned to user with a specific function title. What I have found is how to assign a permission set using the Flow Builder (create a record in the object 'Permission Set Assignment'. But I have not been able to find the same for Permission Set Groups. Is this even possible?

Best Answer

Both PermissionSetAssignments and PermissionSetGroups are accessible as SObjects and can be created in the database when the appropriate permissions exist. I suggest you simply need to create the PermissionSetAssignment for the User referencing the PermissionSetGroup instance. This can be done straight-forwardly in Apex using something like:

PermissionSetAssignment assignment = new PermissionSetAssignment(
    PermissionSetGroupId = groupId,
    AssigneeId = userId);

insert assignment;

Of course, you should ensure this code is bulkified if you are handling bulk provisioning, and can be accessed from a flow as long as you create an InvocableMethod for it.

Related Topic