{"id":"sforce_api_objects_setupentityaccess","title":"SetupEntityAccess","content":"<a name=\"sforce_api_objects_setupentityaccess\"><!-- --></a><h1 class=\"helpHead1\">SetupEntityAccess</h1><div class=\"body\">\n<div class=\"shortdesc\">\n<span class=\"ph\" id=\"summary\"><a name=\"summary\"><!-- --></a>Represents the enabled setup entity access settings (such as for Apex\n         classes) for the parent PermissionSet.</span> This object is available in API version 25.0\n      and later.</div>\n\n      <p class=\"p\">To grant users access to an entity, associate the appropriate SetupEntityAccess record with\n         a PermissionSet that’s assigned to a user.</p>\n\n      <div class=\"section\">\n<h2 class=\"helpHead2\">Supported Calls</h2>\n\n         \n         <p class=\"p\"><samp class=\"codeph nolang\">create()</samp>, <samp class=\"codeph nolang\">delete()</samp>, <samp class=\"codeph nolang\">describeSObjects()</samp>, <samp class=\"codeph nolang\">query()</samp>, <samp class=\"codeph nolang\">retrieve()</samp></p>\n\n      </div>\n\n      <div class=\"section\">\n<h2 class=\"helpHead2\">Special Access Rules</h2>\n\n         \n         <p class=\"p\">As of Spring ’20 and later, only users with \"View Setup and Configuration\" permission\n            can access this object.</p>\n\n      </div>\n\n      <div class=\"section\">\n<h2 class=\"helpHead2\">Fields</h2>\n\n         \n         \n<div class=\"data colSort\"><table class=\"featureTable sort_table\" summary=\"\">\n               \n               \n               <thead class=\"thead sorted\" align=\"left\">\n                  <tr>\n                     <th class=\"featureTableHeader  \" id=\"d1820668e92\">Field Name</th>\n\n                     <th class=\"featureTableHeader  \" id=\"d1820668e95\">Details</th>\n\n                  </tr>\n\n               </thead>\n\n               <tbody class=\"tbody\">\n                  <tr>\n                     <td class=\"entry\" headers=\"d1820668e92\" data-title=\"Field Name\"><span class=\"keyword parmname\" id=\"ParentId\"><a name=\"ParentId\"><!-- --></a>ParentId</span></td>\n\n                     <td class=\"entry\" headers=\"d1820668e95\" data-title=\"Details\">\n                        <dl class=\"dl detailList\">\n                           \n                              <dt class=\"dt dlterm\">Type</dt>\n\n                              <dd class=\"dd\">reference</dd>\n\n                           \n                           \n                              <dt class=\"dt dlterm\">Properties</dt>\n\n                              <dd class=\"dd\">Create, Filter, Group, Sort</dd>\n\n                           \n                           \n                              <dt class=\"dt dlterm\">Description</dt>\n\n                              <dd class=\"dd\">The ID of the entity’s parent PermissionSet.</dd>\n\n                              <dd class=\"dd\">This is a relationship field.</dd>\n\n                           \n                           \n                              <dt class=\"dt dlterm\">Relationship Name</dt>\n\n                              <dd class=\"dd\">Parent</dd>\n\n                           \n                           \n                              <dt class=\"dt dlterm\">Relationship Type</dt>\n\n                              <dd class=\"dd\">Lookup</dd>\n\n                           \n                           \n                              <dt class=\"dt dlterm\">Refers To</dt>\n\n                              <dd class=\"dd\">PermissionSet</dd>\n\n                           \n                        </dl>\n\n                     </td>\n\n                  </tr>\n\n                  <tr>\n                     <td class=\"entry\" headers=\"d1820668e92\" data-title=\"Field Name\"><span class=\"keyword parmname\">SetupEntityId</span></td>\n\n                     <td class=\"entry\" headers=\"d1820668e95\" data-title=\"Details\">\n                        <dl class=\"dl detailList\">\n                           \n                              <dt class=\"dt dlterm\">Type</dt>\n\n                              <dd class=\"dd\">reference</dd>\n\n                           \n                           \n                              <dt class=\"dt dlterm\">Properties</dt>\n\n                              <dd class=\"dd\">Create, Filter, Group, Sort</dd>\n\n                           \n                           \n                              <dt class=\"dt dlterm\">Description</dt>\n\n                              <dd class=\"dd\">The ID of the entity for which access is enabled, such as an Apex\n                                 class or Visualforce\n                                 page.</dd>\n\n                           \n                        </dl>\n\n                     </td>\n\n                  </tr>\n\n                  <tr>\n                     <td class=\"entry\" headers=\"d1820668e92\" data-title=\"Field Name\"><span class=\"keyword parmname\">SetupEntityType</span></td>\n\n                     <td class=\"entry\" headers=\"d1820668e95\" data-title=\"Details\">\n                        <dl class=\"dl detailList\">\n                           \n                              <dt class=\"dt dlterm\">Type</dt>\n\n                              <dd class=\"dd\">picklist</dd>\n\n                           \n                           \n                              <dt class=\"dt dlterm\">Properties</dt>\n\n                              <dd class=\"dd\">Filter, Group, Nillable, Restricted picklist, Sort</dd>\n\n                           \n                           \n                              <dt class=\"dt dlterm\">Description</dt>\n\n                              <dd class=\"dd\">The type of setup entity for which access is enabled. Valid values are:<ul class=\"ul bulletList\">\n                                    <li class=\"li\">\n<span class=\"keyword parmname\">ApexClass</span> for Apex classes</li>\n\n                                    <li class=\"li\">\n<span class=\"keyword parmname\">ApexPage</span> for Visualforce pages</li>\n\n                                    <li class=\"li\">In API version 64.0 and later,\n                                          <span class=\"keyword parmname\">BotDefinition</span> for agents</li>\n\n                                    <li class=\"li\">In API version 28.0 and later,\n                                          <span class=\"keyword parmname\">ConnectedApplication</span> for OAuth\n                                       connected apps</li>\n\n                                    <li class=\"li\">In API version 48.0 and later,\n                                          <span class=\"keyword parmname\">CustomEntityDefinition</span> for Custom\n                                       Settings and Custom Metadata Types</li>\n\n                                    <li class=\"li\">In API version 31.0 and later,\n                                          <span class=\"keyword parmname\">CustomPermission</span> for custom\n                                       permissions</li>\n\n                                    <li class=\"li\">In API version 62.0 and later,\n                                          <span class=\"keyword parmname\">EmailRoutingAddress</span> for email routing\n                                       addresses. </li>\n\n                                    <li class=\"li\">In API version 60.0 and later,\n                                          <span class=\"keyword parmname\">ExternalClientApplication</span> for\n                                       external client apps.</li>\n\n                                    <li class=\"li\">In API version 58.0 and later,\n                                          <span class=\"keyword parmname\">ExternalCredentialParameter</span> for\n                                       external credential principals.</li>\n\n                                    <li class=\"li\">In API version 58.0 and later,\n                                          <span class=\"keyword parmname\">FlowDefinition</span> for flows</li>\n\n                                    <li class=\"li\">In API version 62.0 and later,\n                                          <span class=\"keyword parmname\">MessagingChannel</span> for messaging\n                                       channels</li>\n\n                                    <li class=\"li\">In API version 58.0 and later,\n                                          <span class=\"keyword parmname\">OrgWideEmailAddress</span> for\n                                       organization-wide email addresses</li>\n\n                                    <li class=\"li\">In API version 28.0 and later,\n                                          <span class=\"keyword parmname\">ServiceProvider</span> for service\n                                       providers</li>\n\n                                    <li class=\"li\">In API version 60.0 and later,\n                                          <span class=\"keyword parmname\">StandardInvocableActionType</span> for\n                                       standard invocable actions.</li>\n\n                                    <li class=\"li\">In API version 28.0 and later, <span class=\"keyword parmname\">TabSet</span>\n                                       for apps</li>\n\n                                 </ul>\n</dd>\n\n                           \n                        </dl>\n\n                     </td>\n\n                  </tr>\n\n               </tbody>\n\n            </table></div>\n\n      </div>\n\n      <div class=\"section\">\n<h2 class=\"helpHead2\">Usage</h2>\n\n         \n         <p class=\"p\">Because SetupEntityAccess is a child of the PermissionSet object, the usage is similar\n            to other PermissionSet child objects like FieldPermissions and ObjectPermissions.</p>\n\n         <div class=\"p\">For example, the following code returns all permission sets that grant access to any\n            setup entities for which access is\n            enabled:<div class=\"codeSection soql\"><pre class=\"codeblock brush:plain\">SELECT Id, ParentId, Parent.Name, SetupEntityId\nFROM SetupEntityAccess</pre></div>\n</div>\n\n         <div class=\"p\">The following code returns permission sets that grant access only to Apex\n            classes:<div class=\"codeSection soql\"><pre class=\"codeblock brush:plain\">SELECT Id, ParentId, Parent.Name, SetupEntityId\nFROM SetupEntityAccess\nWHERE SetupEntityType='ApexClass'</pre></div>\n</div>\n\n         <div class=\"p\">The following code returns permission sets that grant access to any setup entities, and\n            are not owned by a\n            profile:<div class=\"codeSection soql\"><pre class=\"codeblock brush:plain\">SELECT Id, ParentId, Parent.Name, SetupEntityId\nFROM SetupEntityAccess\nWHERE ParentId\nIN (SELECT Id\n   FROM PermissionSet\n   WHERE isOwnedByProfile = false)</pre></div>\n</div>\n\n         <div class=\"p\">You may want to return only those permission sets that have access to a specific setup\n            entity. To do this, query the parent object. For example, this code returns all\n            permission sets that grant access to the <samp class=\"codeph apex_code\">helloWorld</samp> Apex\n            class:<div class=\"codeSection soql\"><pre class=\"codeblock brush:plain\">SELECT Id, Name,\n   (SELECT Id, Parent.Name, Parent.Profile.Name\n   FROM SetupEntityAccessItems)\nFROM ApexClass\nWHERE Name = 'helloWorld'</pre></div>\n</div>\n\n         <div class=\"p\">While it’s possible to return permission sets that have access to a\n               <span class=\"keyword parmname\">ConnectedApplication</span>, <span class=\"keyword parmname\">ServiceProvider</span>, or\n               <span class=\"keyword parmname\">TabSet</span> by <span class=\"keyword parmname\">SetupEntityId</span>, it’s not possible\n            to return permission sets that have access to these <span class=\"keyword parmname\">SetupEntityType</span>\n            fields by any other AppMenuItem attribute, such as <span class=\"keyword parmname\">Name</span> or\n               <span class=\"keyword parmname\">Description</span>. For example, to find out if a user has access to\n            the Recruiting app, you’d run two queries. First, query to get the AppMenuItem\n            ID:<div class=\"codeSection soql\"><pre class=\"codeblock brush:plain\">SELECT Id, Name, Label\nFROM AppMenuItem\nWHERE Name = 'Recruiting'</pre></div>\n</div>\n\n         <div class=\"p\">Let’s say the previous query returned the AppMenuItem <span class=\"keyword parmname\">ApplicationId</span>\n            02uD0000000GIiMIAW. Using this ID, you can now run a query to find out if a user has\n            access to the Recruiting\n            app:<div class=\"codeSection soql\"><pre class=\"codeblock brush:plain\">SELECT Id, SetupEntityId, SetupEntityType\nFROM SetupEntityAccess\nWHERE ParentId\nIN\n   (SELECT PermissionSetId \n   FROM PermissionSetAssignment\n   WHERE AssigneeId = '005D0000001QOzF')\nAND (SetupEntityId = '02uD0000000GIiMIAW')</pre></div>\n</div>\n\n      </div>\n\n   </div><div id=\"sfdc:seealso\" class=\"related-links\">\n<div class=\"relinfo\">\n<h4>See Also</h4>\n<ul class=\"unstyled\">\n<li><div><a class=\"link\" href=\"atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_permissionset.htm\" title=\"Represents a set of permissions that’s used to grant more access to one or more users without changing their profile or reassigning profiles. This object is available in API version 22.0 and later.\">PermissionSet</a></div></li>\n<li><div><a class=\"link\" href=\"atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_fieldpermissions.htm\" title=\"Represents the enabled field permissions for the parent PermissionSet. This object is available in API version 24.0 and later.\">FieldPermissions</a></div></li>\n<li><div><a class=\"link\" href=\"atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_objectpermissions.htm\" title=\"Represents the enabled object permissions for the parent PermissionSet. This object is available in API version 24.0 and later.\">ObjectPermissions</a></div></li>\n<li><div><a class=\"link\" href=\"atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_apexclass.htm\" title=\"Represents an Apex class.\">ApexClass</a></div></li>\n<li><div><a class=\"link\" href=\"atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_apexpage.htm\" title=\"Represents a single Visualforce page.\">ApexPage</a></div></li>\n</ul>\n</div>\n</div>"}