Sub topic 10
View All and Modify All: permissions that bypass sharing
Earlier chapters built record access from the bottom up. Org-wide defaults (OWD) set the baseline, ownership and the role hierarchy add access, and sharing rules, teams and manual shares open more. This chapter covers the permissions that skip that whole process. It assumes you know profiles, permission sets and the OWD levels, and that you can read basic SOQL.
Two scopes, four permissions
Salesforce has two pairs of permissions that override sharing. They differ in scope.
| Permission | Scope | Where you set it | What it grants |
|---|---|---|---|
| View All | One object | Object settings in a profile or permission set | Read on every record of that object |
| Modify All | One object | Object settings in a profile or permission set | Read, edit, delete, transfer and approve on every record of that object |
| View All Data | Whole org | System permissions | Read on every record of every object |
| Modify All Data | Whole org | System permissions | Read, edit and delete on every record of every object |
View All and Modify All are often called object-level overrides. In the metadata they appear as PermissionsViewAllRecords and PermissionsModifyAllRecords. View All Data and Modify All Data are system permissions, and they are far broader.
What "bypass" means
Normally the platform checks two things in order. First it checks that your profile or permission sets give you the object permission (Read, Create, Edit or Delete). Then it checks record-level access through OWD, ownership, roles and sharing.
View All and Modify All replace the second check. The platform stops looking at the record's owner, the role hierarchy and the share rows. Everything the record-level layer would have said is irrelevant for that user on that object.
The override sits after the object permission check. It does not replace it.
Prerequisites between permissions
The permissions depend on each other, and the Setup UI enforces this when you tick boxes.
- View All requires Read on the object.
- Modify All requires Read, Create, Edit, Delete and View All on the object.
- Modify All Data includes View All Data.
Modify All on Account therefore also gives View All on Account. It does not give anything on Opportunity. Object-level overrides stay on the one object.
Object-level versus org-wide
Use the narrowest permission that does the job.
- A regional operations team that must audit every Case, and nothing else, needs View All on Case.
- A data steward who cleans duplicate Accounts across all owners needs Modify All on Account.
- An integration user that syncs every object may genuinely need View All Data or Modify All Data. Treat that as a deliberate exception and review it.
View All Data and Modify All Data also carry non-sharing power. Modify All Data allows changes to records in objects the user has no object permission for, along with administrative abilities. Do not give it to "make sharing problems go away". The sharing model is meant to be the control, and these permissions switch it off for the user.
How the overrides interact with the rest of sharing
Some points can surprise you.
- The role hierarchy does not matter. A user with View All on Opportunity sees every opportunity regardless of role position. Turning off Grant Access Using Hierarchies on a custom object has no effect on that user.
- OWD does not matter. Even if an object is Private, a View All holder sees every record. This is why View All is often the right answer for a read-only auditor, and why it is dangerous on a sensitive object.
- Share tables do not show it. The override is not stored as share rows. A query on
AccountSharewill not list a user who has View All on Account. This is a common source of confusion when troubleshooting. UserRecordAccessdoes show it. That object is computed from all mechanisms, so it reports the effective result.- Objects with no sharing of their own. Detail objects in a master-detail relationship inherit access from the parent and do not offer View All or Modify All. You grant access on the master object instead.
- Apex. A class declared
with sharingenforces the running user's record access, and that includes these overrides. If the user has View All Data,with sharingstill returns every record, because that is what the user can see.
Finding who has the overrides
When a user sees records they should not, check the overrides before you look at share rows. Profiles are stored as permission sets in the metadata, so one query covers both.
SELECT Parent.Name, Parent.Label, Parent.IsOwnedByProfile,
PermissionsViewAllRecords, PermissionsModifyAllRecords
FROM ObjectPermissions
WHERE SobjectType = 'Account'
AND (PermissionsViewAllRecords = true OR PermissionsModifyAllRecords = true)Rows where Parent.IsOwnedByProfile is true come from a profile. The others come from permission sets. To find the org-wide permissions:
SELECT Name, Label, IsOwnedByProfile
FROM PermissionSet
WHERE PermissionsViewAllData = true
OR PermissionsModifyAllData = trueThen map those permission sets to users with PermissionSetAssignment. Profile-owned permission sets are assigned through the user's profile, so for those you query User by ProfileId.
You can confirm the effective result with UserRecordAccess, as in earlier chapters:
SELECT RecordId, HasReadAccess, HasEditAccess, HasDeleteAccess
FROM UserRecordAccess
WHERE UserId = '005XXXXXXXXXXXXXXX'
AND RecordId = '001XXXXXXXXXXXXXXX'For a user with Modify All on Account, all three columns are true for every account, even when AccountShare has no row for that user.
Worked example
Your org has Account OWD set to Private. Three users exist.
- Dana is a sales rep with Read, Create and Edit on Account and no overrides. She is not in the role chain above the account owner.
- Marcus is Dana's manager. He has the same object permissions and no overrides, and his role is above the owner's role.
- Priya is an auditor. Her permission set gives Read on Account and View All on Account. Her role is in a separate branch of the hierarchy.
For an account owned by a rep who reports to Marcus:
| User | Why | Read | Edit |
|---|---|---|---|
| Dana | Private OWD, not the owner, not above the owner, no share row | No | No |
| Marcus | The role hierarchy opens the owner's records upward | Yes | Yes |
| Priya | View All on Account bypasses sharing, but she has no Edit | Yes | No |
Priya's case shows an important detail. View All gives read access only. She cannot edit these records unless she also has Modify All, or another sharing mechanism gives her edit access, such as an ownership or share row. Her Edit object permission is also missing, so Modify All would be the clean way to extend her rights.
Common mistakes
- Granting Modify All on an object to fix one user's missing edit access. A manual share or sharing rule gives that user access to the specific records and leaves other records protected.
- Forgetting that the override is per object. Modify All on Opportunity does not expose the related Account.
- Assuming that tightening OWD protects a record from a user with View All. It does not.
- Giving integration users Modify All Data by default. Grant the object permissions the integration needs, and add object-level overrides only where required.
Exercise
An auditor has Read and View All on Case. Case OWD is Private. She is in a role branch unrelated to the Case owners. You query CaseShare for one case and find no row for her. Can she open the case, and can she edit it? How would you confirm?
Show answer
She can open the case, because View All bypasses OWD, ownership, roles and share rows. The missing CaseShare row does not matter. She cannot edit it unless she also has Modify All on Case, or another mechanism gives her edit access along with the Edit object permission. To confirm, query UserRecordAccess with her UserId and the case's RecordId and check HasReadAccess and HasEditAccess. To see why she has read access, query ObjectPermissions for SobjectType = 'Case' where PermissionsViewAllRecords is true.
Exercise
A manager asks for Modify All Data for an analyst who only needs to edit Accounts owned by other teams. What would you grant instead, and why?
Show answer
Grant Modify All on Account through a permission set, or, if only some accounts are involved, use a sharing rule or team access with Edit. Modify All Data covers every object and administrative functions, which is far more than the analyst needs. An object-level override limits the exposure to Account, and a sharing rule limits it to the matching records.