+ Start a Discussion
vleandrovleandro 

Getting Queue Memebers and their respective Permission Set

I have a class that currently does a great job of getting a Queue and then listing all the users for that queue.  Code works great.  I present the query snippit here for reference.
 
// provide queue name to show on page
    public Group selectedQueue {
        get {
            return [
				SELECT
                	id, name
                FROM
                	group
                WHERE
                	id = :queueId
            ];
        }
    }
    
    // list of all active queue members
    public List<User> queueMembers {
        get {
            return [
            	SELECT
                	id, firstName, lastName, username, email, userRole.name, profile.name
                FROM
                	user
                WHERE
                	id IN (SELECT userOrGroupId FROM groupmember WHERE groupId = :queueId )
				AND
               	isActive = true
                ORDER BY firstName ASC                	
            ];
        }
    }

My visualforce page presents the user with the Queue they selected and the users who are members of that Queue (along with their attributes such as name, profile, role, etc.).

Now I want to bring in those users' permission sets.  

I know I can do a SELECT statement against the PermissionSetAssignment object:
 
SELECT Assignee.Name, Assignee.ID, PermissionSet.Label
FROM PermissionSetAssignment
WHERE PermissionSet.IsOwnedByProfile = FALSE

However, I'm struggling with how to build this into the query I have above.  I'm a fairly new developer so any assistance or suggestions would be greatly appreaciated!

Thank you!
Virginia

 
vleandrovleandro
I'm continuing to dig and got a little further but still no brass ring.

Here's the code I'm focusing in on.
 
public class QueueMembersController {

    // selected queue whose members to view
    public ID queueId { get; set; }
    
    // provide queue name to show on page
    public Group selectedQueue {
        get {
            return [
				SELECT
                	id, name
                FROM
                	group
                WHERE
                	id = :queueId
            ];
        }
    }
    
    // list of all active queue members
    public List<User> queueMembers {
        get {
            return [
            	SELECT
                	id, firstName, lastName, username, email, userRole.name, profile.name, BMCServiceDesk__IsStaffUser__c
                FROM
                	user
                WHERE
                	id IN (SELECT userOrGroupId FROM groupmember WHERE groupId = :queueId )
				AND
               	isActive = true
                ORDER BY firstName ASC                	
            ];
        }
    }
    
    public PermissionSetAssignment permsetName {
    	get {
    		return [
    			SELECT
    				id, PermissionSet.Label
    			FROM
    				PermissionSetAssignment
    			WHERE
    				PermissionSet.IsOwnedByProfile = FALSE AND AssigneeId = :user.id
    		];
    	}
    }

 Notice I've now added a new method for PermissionSetAssignment.  However, the following line is giveing me trouble:
 
PermissionSet.IsOwnedByProfile = FALSE AND AssigneeId = :user.id
I get the following error:
Save error: Invalid bind expression type of Schema.SObjectField for column of type Id.

I suspect it's because the ID for User isn't available to this public class?  How can I rewirte such that the user.id is available in the permission set query?