SharingSet

Represents a sharing set. A sharing set defines an access mapping that grants portal or community users access to objects that are associated with their accounts or contacts.

For example, you can grant portal or community users access to all cases related to their account record. Similarly, you can grant portal or community users access to all cases related to a parent account that is identified on the user’s account record.

Parent Type 

This type extends Metadata and inherits its fields.

File Suffix and Directory Location 

SharingSet components have the suffix .sharingSet and are stored in the sharingSets folder.

Version 

Introduced in API version 30.0.

Special Access Rules 

As of Spring ’20 and later, only users with the View Setup and Configuration permission can access this object, and only users with the Manage Sharing permission can edit this object. To create or update sharing sets, you need the Customize Application permission.

Sharing sets are available with these licenses.

  • 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

Fields 

accessMappings 

  • Type: AccessMapping[]
  • Required: No
  • Description: A list of access mappings on a sharing set.

description 

  • Type: string
  • Required: No
  • Description: The sharing set description. Limit: 255 characters.

name 

  • Type: string
  • Required: Yes
  • Description: Required. The unique identifier for API access. Corresponds to Sharing Set Name on the user interface.

profiles 

  • Type: string[]
  • Required: No
  • Description: The profiles of users that are granted access to the target objects. Profiles must be associated with a license that can use sharing sets. See Special Access Rules for more information.

AccessMapping Type 

AccessMapping

You can grant portal users access to a target object, or to both a target object and its associated objects, such as an account and its contacts and cases.

Fields 

accessLevel 

  • Type: string (enumeration of type string)
  • Required: Yes
  • Description: Required. The target object access level granted to the portal user.
  • Possible values:
    • Read
    • Edit

object 

  • Type: string

  • Required: Yes

  • Description: Required. The target object to which the portal user is gaining access, and refers to one of the following:

    • Account
    • Campaign
    • Contact
    • Case
    • Custom Objects (for example, ObjA__c)
    • Opportunity
    • Order
    • ServiceContract
    • User
    • WorkOrder

    Portal users gain access to all order entitlements and order items under an account to which they have access.

objectField 

  • Type: string
  • Required: Yes
  • Description: Required. A lookup to the target object, which supports standard or custom fields, or an ID. For accounts or cases associated with entitlements, use Entitlement.Account or Entitlement.Case.

userField 

  • Type: string (enumeration of type string)

  • Required: Yes

  • Description: Required. The user’s lookup to an account, contact, or a standard or custom field derived from an account or contact. Either the user or the user’s manager can be used in the lookup.

    Field refers to a standard or custom field based on an account or contact.

  • Possible values:

    • Account
    • Account. Field
    • Contact
    • Contact. Field
    • Contact.RelatedAccount
    • Manager.Account
    • Manager.Contact

Declarative Metadata Sample Definition 

The following is an example of a SharingSet component that grants users access to all contacts whose ReportsTo fields match the users’ contacts.

1<?xml version="1.0" encoding="UTF-8"?>
2<SharingSet xmlns="http://soap.sforce.com/2006/04/metadata">
3  <accessMappings>
4    <accessLevel>Read</accessLevel>
5    <objectField>ReportsTo</objectField>
6    <object>Contact</object>
7    <userField>Contact</userField>
8  </accessMappings>
9  <description>User Access Mapping</description>
10  <name>User</name>
11  <profiles>customer community user</profiles>
12</SharingSet>

The following is an example of a SharingSet component that grants users access to all cases that are related to an entitlement, which is associated with the user’s account.

1<?xml version="1.0" encoding="UTF-8"?>
2<SharingSet xmlns="http://soap.sforce.com/2006/04/metadata">
3  <name>Case</name>
4   <accessMappings>
5    <accessLevel>Edit</accessLevel>
6    <objectField>Entitlement.Account</objectField>
7    <object>Case</object>
8    <userField>Account</userField>
9  </accessMappings>
10</SharingSet>

The following is an example of a SharingSet component with a list of access mappings.

1<?xml version="1.0" encoding="UTF-8"?>
2<SharingSet xmlns="http://soap.sforce.com/2006/04/metadata">
3  <description>This is a basic sharing set with several access mappings.</description>
4  <name>Basic</name>
5  <profiles>customer community user</profiles>
6  <accessMappings>
7    <accessLevel>Read</accessLevel>
8    <objectField>Id</objectField>
9    <object>Account</object>
10    <userField>Account</userField>
11  </accessMappings>
12  <accessMappings>
13    <accessLevel>Edit</accessLevel>
14    <objectField>Account</objectField>
15    <object>Contact</object>
16    <userField>Account</userField>
17  </accessMappings>
18  <accessMappings>
19    <accessLevel>Edit</accessLevel>
20    <objectField>Contact</objectField>
21    <object>Case</object>
22    <userField>Contact</userField>
23  </accessMappings>
24  <accessMappings>
25    <accessLevel>Read</accessLevel>
26    <objectField>AccountLookup__c</objectField>
27    <object>HVPUAccessible__c</object>
28    <userField>Account</userField>
29  </accessMappings>
30</SharingSet>

The following is an example package.xml that references the previous definition.

1<Package xmlns="http://soap.sforce.com/2006/04/metadata">
2  <fullName>SharingSetBasic</fullName>
3  <types>
4    <members>HVPUAccessible__c.AccountLookup__c</members>
5    <members>HVPUAccessible__c.ContactLookup__c</members>
6    <name>CustomField</name>
7  </types>
8  <types>
9    <members>HVPUAccessible__c</members>
10    <name>CustomObject</name>
11  </types>
12  <types>
13    <members>Basic</members>
14    <name>SharingSet</name>
15  </types>
16  <version>30.0</version>
17</Package>

Wildcard Support in the Manifest File 

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.