Loading

Create manual sharing rules with Data Loader

Date de publication: Oct 13, 2022
Description

It is possible to create manual sharing rules for some Salesforce objects using the Data Loader tool. This article explains how to prepare the required CSV file and insert sharing records directly into Salesforce sharing tables such as AccountShare, CaseShare, LeadShare, and OpportunityShare.

Résolution

Determine if the Object Supports Sharing via Data Loader

To determine if a standard object supports sharing rule creation via the Data Loader, review the Introducing SOAP API documentation and search for the object name plus "Share" (for example, AccountShare). If the share object is not listed, the object does not support sharing rule creation via the Data Loader (for example, EventShare and TaskShare are not supported).

Prepare the CSV File

Create a CSV file that includes three columns:

  1. Record ID — Label this column AccountID, CaseID, LeadID, or OpportunityID depending on the object. Obtain record IDs by creating and exporting a Salesforce report that lists the records you want to share, including the Salesforce ID.
  2. UserOrGroupID — The ID of the User or Public Group receiving access. Obtain the User ID by exporting a User report or the User/Group table using Data Loader.
  3. Access Level — Label this column AccountAccessLevel, CaseAccessLevel, LeadAccessLevel, or OpportunityAccessLevel depending on the object. Use one of the following values:
    1. Read — User or Group can only view the record.
    2. Edit — User or Group can view and edit the record.

The access level must be at least equal to, or less restrictive than, the organization's default access level for the object. Sharing rules are designed to extend access, not restrict it.
For the Account object, a completed CSV file looks like this:
 

AccountIDUserOrGroupIDAccountAccessLevel
001000000012345005000000023456Edit

Example scenarios:

  • If the org-wide default for Cases is Public Read/Write, all users already have Read/Write access, so creating sharing rules to set Read-only access for a subset of users is not applicable.
  • If the org-wide default for Cases is Private, you can use sharing rules to open Read or Edit access to other users or groups.

Insert Records Using Data Loader

After preparing the CSV file, use Data Loader to insert (create) records into the appropriate sharing table, such as AccountShare, CaseShare, LeadShare, or OpportunityShare. Enable the "Show all Salesforce objects" checkbox in Data Loader when selecting your data object to see sharing tables.
The new sharing rule entry appears as a "Manual" sharing rule, as if it was created by clicking the "Share" button directly on the record in Salesforce.

Notes on Custom Objects

    • The sharing objects for custom objects are not available if the org-wide default access is set to Public Read/Write.
    • A sharing rule object is created for each custom object that does not have a master-detail relationship to another object.
    • The user creating the custom object must have the "Manage Sharing" permission for a sharing rule object to be automatically created.
    • Custom objects that meet the criteria above appear in the Data Loader "Show all Salesforce objects" view as: Share: CustomObjectName (CustomObjectName__Share). 
Ressources supplémentaires

Install Data Loader

Numéro d’article de la base de connaissances

000385389

 
Chargement
Salesforce Help | Article