Posts

Showing posts with the label SetupEntityAccess

Salesforce Fact #656 | Inserting data into SetupEntityAccess

Similar to retrieving data, we can insert rows using apex as well in SetupEntityAccess object for custom permission. Example code: SetupEntityAccess sea = new SetupEntityAccess(); sea.ParentId='0PS6F0000057tXt'; // this is the permission set Id sea.SetupEntityId='0CP6F000000XkviWAC'; // this is the custom permission Id insert sea; Note: If an attempt is made to insert row for an already existing combination, the error 'DUPLICATE_VALUE, duplicate value found:' is shown.

Salesforce Fact #654 | Custom permission assignments

Image
Suppose we have a scenario where we need to find out a particular custom permission is assigned to which all permission sets. There is an object called SetupEntityAccess which is helpful in this case to get the details. In this example, we are getting the details for a custom permission named ' Test_Custom_Permission'. SOQL used ->  SELECT Id, Parent.name, SetupEntityId, SetupEntityType, SystemModstamp FROM SetupEntityAccess  WHERE parent.isownedbyprofile=False AND SetupEntityId IN (SELECT Id FROM CustomPermission  WHERE DeveloperName='Test_Custom_Permission') Attached is the screenshot.