Sub topic 2
Record ownership as the starting point
Every record in Salesforce has an owner, and ownership is the first source of record access. This chapter covers what the owner can do, how ownership is assigned and changed, and which other access mechanisms start from the owner. Later chapters build on it: org-wide defaults, the role hierarchy, and owner-based sharing rules.
This chapter assumes you can navigate Setup, know the difference between standard and custom objects, and understand at a high level that profiles and permission sets grant object and field permissions. The optional code uses basic SOQL.
What ownership means
The owner of a record is the user, or for some objects the queue, named in the record's OwnerId field. The owner gets the highest level of record access: they can view, edit, transfer, delete, and share the record. This is true even when the org-wide default for the object is Private.
Ownership grants record access only. The user still needs object permissions from a profile or permission set. A user who owns an Invoice record but has lost Read permission on the Invoice object cannot open it. Record access and object permissions are separate checks, and both must pass.
| Check | Question it answers | Where it is configured |
|---|---|---|
| Object permission | Can this user work with this type of record at all? | Profile or permission set |
| Field-level security | Can this user see or edit this field? | Profile or permission set |
| Record access | Can this user see or edit this particular record? | Ownership, org-wide defaults, hierarchy, sharing |
Who can own a record
Most objects require a single active user as the owner. Some objects also allow queues. Lead, Case, and custom objects can have queue ownership if you enable queues for that object. Queues are covered in a later chapter.
Some objects have no owner field because they are not independent records. Detail records in a master-detail relationship take their access from the master record. Their owner is not stored separately, and you cannot share them on their own. A custom object on the detail side of a master-detail relationship has no Sharing button for this reason.
| Object type | Ownership behavior |
|---|---|
| Standard objects such as Account, Contact, and Opportunity | Owned by a user |
| Lead and Case | Owned by a user or a queue |
| Custom object (independent) | Owned by a user, or a queue if enabled |
| Detail side of master-detail | No owner. Access is controlled by the master record |
| Child side of lookup | Has its own owner and its own access |
Default ownership on creation
When a user creates a record, they become the owner unless something changes it. These are the common exceptions:
- Assignment rules for leads and cases set the owner to a user or queue when the record is created.
- Web-to-Lead and Web-to-Case use a default owner or assignment rules, because no logged-in user exists.
- Apex, Flow, or the API can set
OwnerIdexplicitly on insert. - Lead conversion creates an account, contact, and optionally an opportunity, owned by the converting user or by the lead owner, depending on the options chosen.
When a record is created by an integration user, that user becomes the owner. This often surprises teams. The integration user owns thousands of records, and nobody else can see them under a Private default. Set OwnerId deliberately in integration code.
Transferring ownership
Changing the owner is called a transfer. A user can transfer a record they own. A user with the Transfer Record permission and at least Read access to the record can also transfer it. Users higher in the role hierarchy can transfer records owned by people below them, if the object is configured to grant access using hierarchies.
Transfers have side effects that matter for access:
- The previous owner loses owner-level access. They keep access only if another mechanism applies, such as a role hierarchy position, a sharing rule, or a team membership.
- Manual shares for the previous owner are removed. Salesforce deletes the Manual shares on a record when its owner changes. This is the main reason manual sharing is considered temporary.
- Related records may move too. When an account's owner changes, open opportunities and cases owned by the previous account owner can be transferred, depending on the options chosen. Contacts transfer with the account when they are owned by the same user.
- Sharing rules are re-evaluated. If an owner-based rule targets records owned by a role or group, the new owner may place the record in or out of that rule's scope.
You can transfer many records at once with the Mass Transfer Records tool in Setup, the Data Loader, or a Flow or Apex update to OwnerId.
Invoice__c invoice = [
SELECT Id, OwnerId
FROM Invoice__c
WHERE Name = 'INV-0001'
LIMIT 1
];
invoice.OwnerId = UserInfo.getUserId();
Database.SaveResult result = Database.update(invoice, false);
if (!result.isSuccess()) {
System.debug(result.getErrors()[0].getMessage());
}This code assigns the invoice to the running user and reports a failure without throwing an exception.
Ownership in the share table
Salesforce stores access to a record in a share table for that object. For a custom object named Invoice, the table is Invoice__Share. Standard objects use names like AccountShare and OpportunityShare.
The owner's access is recorded with the row cause Owner. You can see this by querying the share table:
SELECT Id, ParentId, UserOrGroupId, AccessLevel, RowCause
FROM Invoice__Share
WHERE ParentId = '<invoice record Id>'Expect a row where RowCause is Owner and AccessLevel is All. Two details are worth knowing:
- Owner rows are implicit. You cannot insert, update, or delete them through the share table. The only way to change them is to change
OwnerId. - When the org-wide default is Public Read/Write, the object does not have a share table that you can query. Everyone already has access, so Salesforce does not store individual rows. Querying such a table returns an error because it does not exist for that object.
Later chapters return to share tables and row causes in detail.
Where ownership feeds other mechanisms
Ownership is the input for several later mechanisms. It helps to see the dependencies.
- Role hierarchy. Access is granted upward from the owner. A manager sees records owned by their direct and indirect reports. What matters is the owner's role, not the role of the user who created the record.
- Owner-based sharing rules. These select records by the owner's role, role and subordinates, or public group membership. If the owner changes, the record can enter or leave the rule.
- Manual sharing. The owner, and users with sufficient access such as managers above the owner and administrators, can share a record with others. These shares are lost on transfer.
- Account teams. The account owner is a natural team member, but team access is separate and is added in addition to the owner's.
Ownership and the org-wide default
The org-wide default sets the baseline for everyone who is not the owner. Under Private, only the owner and users above them in the hierarchy have access. Under Public Read Only, everyone can read, but only the owner and those above can edit. The owner's access does not depend on the default.
This is why choosing owners well matters. If you assign records to a generic admin user, people below that admin in the hierarchy gain nothing, and people above gain access to everything. If you assign records to a queue, access follows the queue's members and managers instead.
Common problems
- A user created a record and cannot see it later. The record was transferred away, perhaps by an assignment rule or a mass transfer. The user lost owner access and no other mechanism applies.
- A manager cannot see a report's records. Check that Grant Access Using Hierarchies is enabled for the object. Custom objects have this option, and it can be turned off. Also check whether the manager's role really sits above the owner's.
- Manual shares vanished. The record owner changed. Salesforce removes Manual shares on transfer.
- A user cannot open a record they own. The user probably lacks Read permission on the object. Fix the profile or permission set.
- Records owned by an inactive user. Records remain owned by deactivated users. Users above them in the hierarchy still see the records, but the owner cannot act. Transfer the records before you deactivate a user. Freezing a user is an alternative when you only need to block login temporarily.
Checking ownership with SOQL
You can find who owns what, and spot ownership problems, with a simple aggregate query. This one counts invoices by owner:
SELECT OwnerId, COUNT(Id) total
FROM Invoice__c
GROUP BY OwnerId
ORDER BY COUNT(Id) DESCA very large count under one user usually points to an integration or a default owner that needs review.
Exercise
A sales rep owns an Invoice record that a colleague has had Read access to through a Manual share. An administrator transfers the invoice to another rep. What happens to the colleague's access, and why?
Show answer
The colleague loses access unless another mechanism still grants it, such as a sharing rule, the role hierarchy, or a team. Salesforce removes Manual shares when the record owner changes, so the colleague's share row with the Manual row cause is deleted.
Exercise
A user owns an Account but sees an insufficient privileges error when opening it. The org-wide default for Account is Private. What is the most likely cause?
Show answer
The user's profile and permission sets lack Read permission on the Account object. Ownership grants record access, but object permissions are checked separately and must also allow the action.