SharingSet grants portal or community users access to records associated with their accounts or contacts. It combines a profile-based user population with access mappings: rules that match a relationship on a target record to a relationship on the user or the user's manager.
A sharing set can contain multiple mappings, such as separate mappings for an account, its contacts, and its cases. Each AccessMapping is part of the SharingSet component, not an independently deployable asset.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The component identity inherited from the base Metadata type. |
name |
Required unique API identifier. Corresponds to Sharing Set Name in the user interface. |
profiles |
Repeatable list of profiles whose users are eligible for the sharing set. Each profile must use a license that supports sharing sets. |
accessMappings |
List of contained AccessMapping definitions. Multiple entries can grant access to different target objects. |
accessLevel |
Required within each mapping. Accepts exactly Read or Edit, not an arbitrary permission name. |
object |
Required target object. Supported values are Account, Campaign, Contact, Case, Opportunity, Order, ServiceContract, User, WorkOrder, and custom object API names such as ObjA__c. |
objectField |
Required target-side lookup field or relationship path. Supports standard or custom lookup fields, or Id. Entitlement-related paths include Entitlement.Account and Entitlement.Case. |
userField |
Required user-side relationship. Accepts Account, Account.Field, Contact, Contact.Field, Contact.RelatedAccount, Manager.Account, or Manager.Contact. Field represents a standard or custom field based on Account or Contact. |
description |
Description of the sharing set, limited to 255 characters. |
Behavior and Constraints
A mapping grants access where its target-side objectField value matches its user-side userField value. The selected profiles determine who is eligible; the mapping paths determine which records match. The actual users and records affected depend on profile assignments and relationship values in the org, not just the metadata.
Account access and related-record access are different mappings
These combinations produce different access scopes:
-
object=Account,objectField=Id, anduserField=Accountgrant access to the user's account. -
object=Contact,objectField=Account, anduserField=Accountgrant access to contacts associated with the user's account. -
object=Case,objectField=Contact, anduserField=Contactgrant access to cases associated with the user's contact. -
object=Contact,objectField=ReportsTo, anduserField=Contactgrant access to contacts whose Reports To relationship points to the user's contact.
Use separate entries in accessMappings to represent these target objects in one sharing set. Each entry carries its own accessLevel.
Relationship paths can extend beyond the user's own account or contact
A supported field on the user's account can identify a parent account, allowing a mapping to match records related to that parent account. The Manager.Account and Manager.Contact values instead use the manager's relationship, not the user's own account or contact.
For entitlement-related access, object=Case, objectField=Entitlement.Account, and userField=Account grant access to cases whose entitlement is associated with the user's account. Interpret dotted values such as Entitlement.Account and Manager.Contact as relationship paths, not single field names.
Account access also has a related-record consequence: portal users gain access to all order entitlements and order items under an account to which they have access.
Administrative permissions and license eligibility
Viewing sharing set configuration requires View Setup and Configuration. Editing requires Manage Sharing, and creating or updating sharing sets requires Customize Application.
Every profile in profiles must be associated with a license that supports sharing sets. Supported licenses are:
- Authenticated Website
- Customer Community Login
- Customer Community Plus
- Partner Community
- Customer Community User
- High Volume Customer Portal
- High Volume Portal
- Overage Authenticated Website User
- Overage High Volume Customer Portal User
A profile missing from the setup selector is not, by itself, proof of an unsupported license. An existing sharing-set assignment is another reported cause.
Deployment and Retrieval
SharingSet components use the .sharingSet suffix and reside in the sharingSets folder. In package.xml, specify SharingSet as the metadata type and the component API identifier as the member. For example, a component named Basic is selected with member Basic. The type supports the * wildcard in the manifest.
Deploy and retrieve access mappings as part of their containing sharing set. Do not treat AccessMapping entries as separate manifest members.
Dependency checks must cover both sides of each mapping:
-
profilesreferences the eligible profiles, whose licenses must support sharing sets. -
objectidentifies the target object, including a custom object when applicable. -
objectFieldcan depend on a custom field on the target-side path. -
userFieldcan depend on objects and fields along the user-side path.
For example, a mapping with object=HVPUAccessible__c and objectField=AccountLookup__c depends on that custom object and lookup field. When moving those dependencies with the sharing set, the manifest can include HVPUAccessible__c under CustomObject and HVPUAccessible__c.AccountLookup__c under CustomField.
Keep user eligibility separate from record matching when reviewing a deployment. Changing profiles changes the eligible population; changing objectField or userField changes which records match.
Relationships
The main dependencies are the selected profiles, the target object, and fields on either side of the match. Preserve the distinction between target-side and user-side paths when assessing the impact of object or field changes.
References
-
CustomObject:object,userField. -
CustomField:objectField,userField. -
Profile:profiles.
Reported Issues
- A profile can be missing from Available Profiles because it already belongs to a sharing set. A December 2020 community answer reported a one-sharing-set-per-profile restriction when a Customer Community User profile was absent from the selector. The reported solution was to find the existing sharing set and add the additional object mapping there, rather than create another sharing set for that profile. See the missing-profile discussion.
Common Questions
How do I retrieve a SharingSet with package.xml?
Use metadata type SharingSet and the component API identifier as the member, or use *. The retrieved component uses the .sharingSet suffix in the sharingSets folder. Its access mappings are contained in that component.
Why is my Customer Community profile missing from the sharing set selector?
The profile must have a supported license. Also check whether it already belongs to a sharing set: a community report describes that condition hiding the profile from the selector and recommends adding mappings to the existing sharing set.
How do I share both an account and its contacts?
Use separate mappings. For the account, set object=Account, objectField=Id, and userField=Account. For its contacts, set object=Contact, objectField=Account, and userField=Account. Set Read or Edit independently on each mapping.
Can a sharing set use a manager or parent account relationship?
Yes. userField supports Manager.Account and Manager.Contact. It also supports fields based on Account or Contact, including a supported parent-account relationship identified on the user's account.