Tag Archives: Permission Set

Salesforce Check Permission Set in Custom Button

{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}

var result = sforce.connection.query("SELECT Id FROM PermissionSetAssignment WHERE PermissionSet.Name = 'Sample_Permission_Set' AND AssigneeId = '{!$User.Id}'");
var psAssignment = result.getArray("records");

if (psAssignment.length === 1) {
    //Write your logic
} else {
    alert('You don't have access to this feature.');
}

Get Number of Active Users In a Permission Set Using SOQL Query

SQOL Query:

SELECT COUNT(AssigneeId) FROM PermissionSetAssignment WHERE Assignee.isActive = true AND PermissionSet.Name = 'My_Sample_PermissionSet'

Note: Change the Permission Set API Name as per your requirement.