April 11, 2015

How to find the number of Permission Set assigned to an user in Salesforce?

Sample Code:

Map<Id, List<PermissionSetAssignment>> mapUserIdPermAssignList = new Map<Id, List<PermissionSetAssignment>>();
List<PermissionSetAssignment> listPermAssign = [SELECT AssigneeId, PermissionSetId FROM PermissionSetAssignment];

for(PermissionSetAssignment PA : listPermAssign) {
if(!mapUserIdPermAssignList.containsKey()) {
mapUserIdPermAssignList.put(PA.AssigneeId, new List<PermissionSetAssignment>());

here mapUserIdPermAssignList contains User Id and their related list of Permission Set.


No comments:

Post a Comment