---
schema_version: "1"
id: 7ee9af2d60bb7e69dc7e2b7d93262f6f969bb69fcac4c6f09ebc3a70c710831e
title: SharingSet
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_sharingset.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_sharingset.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 5bc3b046a69c01bafe2cdef4f5128333adaf419117c8677b29a034178fc48bd1
description: 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.
---
# 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.

This type extends the [Metadata](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/metadata.htm "The base class for all metadata types. You can’t edit this object. A component is an instance of a metadata type.") metadata type and inherits its fullName field.

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.

## File Suffix and Directory Location

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

## Version

SharingSet components are available in API version 30.0 and later.

## 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

| Field Name | Field Type | Description |
| --- | --- | --- |
| accessMappings | [AccessMapping](#SubTypeID)\[\] | A list of access mappings on a sharing set. |
| description | string | The sharing set description. Limit: 255 characters. |
| name | string | Required. The unique identifier for API access. Corresponds to **Sharing Set Name** on the user interface. |
| profiles | string\[\] | 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](#Special_Access_Rules) for more information. |

## AccessMapping

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.

<table class="featureTable sort_table" summary="">



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d867894e255">Field Name</th>

              <th class="featureTableHeader  " id="d867894e258">Field Type</th>

              <th class="featureTableHeader  " id="d867894e261">Description</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d867894e255" data-title="Field Name"><span class="keyword parmname">accessLevel</span></td>

              <td class="entry" headers="d867894e258" data-title="Field Type">string</td>

              <td class="entry" headers="d867894e261" data-title="Description">Required. The target object access level granted to the portal user. Valid
                values are:<ul class="ul bulletList">
                  <li class="li"><samp class="codeph nolang">Read</samp></li>

                  <li class="li"><samp class="codeph nolang">Edit</samp></li>

                </ul>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d867894e255" data-title="Field Name"><span class="keyword parmname">objectField</span></td>

              <td class="entry" headers="d867894e258" data-title="Field Type">string</td>

              <td class="entry" headers="d867894e261" data-title="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 <samp class="codeph nolang">Entitlement.Account</samp> or <samp class="codeph nolang">Entitlement.Case</samp>.</td>

            </tr>

            <tr>
              <td class="entry" headers="d867894e255" data-title="Field Name"><span class="keyword parmname">object</span></td>

              <td class="entry" headers="d867894e258" data-title="Field Type">string</td>

              <td class="entry" headers="d867894e261" data-title="Description">Required. The target object to which the portal user is gaining access, and
                refers to one of the following:<ul class="ul bulletList">
                  <li class="li"><samp class="codeph nolang">Account</samp></li>

                  <li class="li"><samp class="codeph nolang">Campaign</samp></li>

                  <li class="li"><samp class="codeph nolang">Contact</samp></li>

                  <li class="li"><samp class="codeph nolang">Case</samp></li>

                  <li class="li">Custom Objects (for example, <samp class="codeph nolang">ObjA__c</samp>)</li>

                  <li class="li"><samp class="codeph nolang">Opportunity</samp></li>

                  <li class="li"><samp class="codeph nolang">Order</samp></li>

                  <li class="li"><samp class="codeph nolang">ServiceContract</samp></li>

                  <li class="li"><samp class="codeph nolang">User</samp></li>

                  <li class="li"><samp class="codeph nolang">WorkOrder</samp></li>

                </ul>
                <p class="p">Portal users gain access to all order entitlements and order items under an
                  account to which they have access. </p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d867894e255" data-title="Field Name"><span class="keyword parmname">userField</span></td>

              <td class="entry" headers="d867894e258" data-title="Field Type">string</td>

              <td class="entry" headers="d867894e261" data-title="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. Valid values are:<ul class="ul bulletList">
                  <li class="li"><samp class="codeph nolang">Account</samp></li>

                  <li class="li"><samp class="codeph nolang">Account.<var class="keyword varname">Field</var></samp></li>

                  <li class="li"><samp class="codeph nolang">Contact</samp></li>

                  <li class="li"><samp class="codeph nolang">Contact.<var class="keyword varname">Field</var></samp></li>

                  <li class="li"><samp class="codeph nolang">Contact.RelatedAccount</samp></li>

                  <li class="li"><samp class="codeph nolang">Manager.Account</samp></li>

                  <li class="li"><samp class="codeph nolang">Manager.Contact</samp></li>

                </ul>
                <p class="p"><samp class="codeph nolang"><var class="keyword varname">Field</var></samp> refers to a
                  standard or custom field based on an account or contact.</p>
              </td>

            </tr>

          </tbody>

        </table>

## 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.

<?xml version="1.0" encoding="UTF-8"?>
<SharingSet xmlns="http://soap.sforce.com/2006/04/metadata">
  <accessMappings\>
    <accessLevel\>Read</accessLevel\>
    <objectField\>ReportsTo</objectField\>
    <object\>Contact</object\>
    <userField\>Contact</userField\>
  </accessMappings\>
  <description\>User Access Mapping</description\>
  <name\>User</name\>
  <profiles\>customer community user</profiles\>
</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.

<?xml version="1.0" encoding="UTF-8"?>
<SharingSet xmlns="http://soap.sforce.com/2006/04/metadata">
  <name\>Case</name\>
   <accessMappings\>
    <accessLevel\>Edit</accessLevel\>
    <objectField\>Entitlement.Account</objectField\>
    <object\>Case</object\>
    <userField\>Account</userField\>
  </accessMappings\>
</SharingSet\>

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

<?xml version="1.0" encoding="UTF-8"?>
<SharingSet xmlns="http://soap.sforce.com/2006/04/metadata">
  <description\>This is a basic sharing set with several access mappings.</description\>
  <name\>Basic</name\>
  <profiles\>customer community user</profiles\>
  <accessMappings\>
    <accessLevel\>Read</accessLevel\>
    <objectField\>Id</objectField\>
    <object\>Account</object\>
    <userField\>Account</userField\>
  </accessMappings\>
  <accessMappings\>
    <accessLevel\>Edit</accessLevel\>
    <objectField\>Account</objectField\>
    <object\>Contact</object\>
    <userField\>Account</userField\>
  </accessMappings\>
  <accessMappings\>
    <accessLevel\>Edit</accessLevel\>
    <objectField\>Contact</objectField\>
    <object\>Case</object\>
    <userField\>Contact</userField\>
  </accessMappings\>
  <accessMappings\>
    <accessLevel\>Read</accessLevel\>
    <objectField\>AccountLookup\_\_c</objectField\>
    <object\>HVPUAccessible\_\_c</object\>
    <userField\>Account</userField\>
  </accessMappings\>
</SharingSet\>

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

<Package xmlns="http://soap.sforce.com/2006/04/metadata">
  <fullName\>SharingSetBasic</fullName\>
  <types\>
    <members\>HVPUAccessible\_\_c.AccountLookup\_\_c</members\>
    <members\>HVPUAccessible\_\_c.ContactLookup\_\_c</members\>
    <name\>CustomField</name\>
  </types\>
  <types\>
    <members\>HVPUAccessible\_\_c</members\>
    <name\>CustomObject</name\>
  </types\>
  <types\>
    <members\>Basic</members\>
    <name\>SharingSet</name\>
  </types\>
  <version\>30.0</version\>
</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](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/file_based_zip_file.htm).