1

Profile has a setting "Modify All Data". How can we access "Modify All Data" in apex and in which object it is stored.

3

This permission can read from the PermissionSet object. All profiles have a Permission Set associated with them, you can read more about this in the documentation, specifically the section Associated Profiles.

In API version 25.0 and later, every profile is associated with a permission set that stores the profile’s user, object, and field permissions, as well as setup entity access settings. Permission sets that are owned by profiles can be queried but not modified.

The documentation also provides the following sample query.

When combined with the PermissionSetAssignment object, you can create a nested query that returns all users assigned to a particular permission like “Modify All Data”:

SELECT Name, (SELECT AssigneeId FROM Assignments)
FROM PermissionSet
WHERE PermissionsModifyAllData=true
|improve this answer|||||
2

This query gives you a list of all users that have the Modify All Data permission (through profile or through a permission set).

SELECT AssigneeId FROM PermissionSetAssignment
WHERE PermissionSet.PermissionsModifyAllData = true

You can easily convert this into a SET and then use the contains method in order to check if the current user has these permissions.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.