Newer Version Available
SetupEntityAccess
Represents the enabled setup entity access
settings (such as for Apex classes) for the parent PermissionSet. This object is
available in API version 25.0 and later.
To grant users access to an entity, associate the appropriate SetupEntityAccess record with a PermissionSet that’s assigned to a user.
Supported Calls
create(), delete(), describeSObjects(), query(), retrieve()
Special Access Rules
As of Spring ���20 and later, only users with "View Setup and Configuration" permission can access this object.
Fields
Usage
Because SetupEntityAccess is a child of the PermissionSet object, the usage is similar to other PermissionSet child objects like FieldPermissions and ObjectPermissions.
For example, the following code returns all permission sets that grant access to any
setup entities for which access is
enabled:
1SELECT Id, ParentId, Parent.Name, SetupEntityId
2FROM SetupEntityAccessThe following code returns permission sets that grant access only to Apex
classes:
1SELECT Id, ParentId, Parent.Name, SetupEntityId
2FROM SetupEntityAccess
3WHERE SetupEntityType='ApexClass'The following code returns permission sets that grant access to any setup entities, and
are not owned by a
profile:
1SELECT Id, ParentId, Parent.Name, SetupEntityId
2FROM SetupEntityAccess
3WHERE ParentId
4IN (SELECT Id
5 FROM PermissionSet
6 WHERE isOwnedByProfile = false)You may want to return only those permission sets that have access to a specific setup
entity. To do this, query the parent object. For example, this code returns all
permission sets that grant access to the helloWorld Apex
class:
1SELECT Id, Name,
2 (SELECT Id, Parent.Name, Parent.Profile.Name
3 FROM SetupEntityAccessItems)
4FROM ApexClass
5WHERE Name = 'helloWorld'While it’s possible to return permission sets that have access to a
ConnectedApplication, ServiceProvider, or
TabSet by SetupEntityId, it’s not
possible to return permission sets that have access to these
SetupEntityType fields by any other AppMenuItem attribute, such
as Name or Description. For example, to find
out if a user has access to the Recruiting app, you’d run two queries. First,
query to get the AppMenuItem
ID:
1SELECT Id, Name, Label
2FROM AppMenuItem
3WHERE Name = 'Recruiting'Let’s say the previous query returned the AppMenuItem ID 02uD0000000GIiMIAW.
Using this ID, you can now run a query to find out if a user has access to the
Recruiting
app:
1SELECT Id, SetupEntityId, SetupEntityType
2FROM SetupEntityAccess
3WHERE ParentId
4IN
5 (SELECT PermissionSetId
6 FROM PermissionSetAssignment
7 WHERE AssigneeId = '005D0000001QOzF')
8AND (SetupEntityId = '02uD0000000GIiMIAW')