+ Start a Discussion
N.iguN.igu 

not working

PermissionSet perm = [SELECT Name FROM PermissionSet WHERE Name = 'AccountAdmin' LIMIT 1];

List<PermissionSetAssignment> assignList = [SELECT AssigneeId FROM PermissionSetAssignment WHERE AssigneeId =: perm.Id];

List<Id> UserIds = new List<Id>();

public Boolean getNewAdd(){
    
      for(PermissionSetAssignment assign : assignList){
        UserIds.add(assign.AssigneeId);
          System.debug('[UserIds] ' + assign.AssigneeId);
      }
      if(UserIds.contains(UserInfo.getUserId()) ){
            return true;
        }else{
            return false;
      }
}
Bhargavi TunuguntlaBhargavi Tunuguntla
Hi 

Please use the below code :
 
PermissionSet perm = [SELECT Name FROM PermissionSet WHERE Name = 'AccountAdmin' LIMIT 1];

List<PermissionSetAssignment> assignList = [SELECT AssigneeId FROM PermissionSetAssignment WHERE PermissionSetId =: perm.Id];

List<Id> UserIds = new List<Id>();

public Boolean getNewAdd(){
    
      for(PermissionSetAssignment assign : assignList){
        UserIds.add(assign.AssigneeId);
          System.debug('[UserIds] ' + assign.AssigneeId);
      }
      if(UserIds.contains(UserInfo.getUserId()) ){
            return true;
        }else{
            return false;
      }
}

As we need compare PermissionSetAssignment field 'PermissionSetId' instead of 'AssigneeId' in line 2.
Thanks
Bhargavi.