How do I create manual sharing rules with the Data Loader?
|Knowledge Article Number||000005614|
|Description||How do I create manual sharing rules for standard and custom objects with the Data Loader?|
|Resolution||To mass insert (create) manual sharing rules for any standard object or custom object using the Data Loader, you need three columns in a .csv data file containing:
1. Record ID (e.g., AccountID, CaseID, LeadID, or OpportunityID)
You can obtain this by creating and exporting a report that lists the records you want to share.
2. User or Public Group ID (UserOrGroupID)
You can get the User ID by creating and exporting a User report. Using the Data Loader, you can export the User or Group table.
3. Access Level (e.g., AccountAccessLevel, CaseAccessLevel, LeadAccessLevel, or OpportunityAccessLevel)
One of the following values must be used:
* Read - User or Group can only view the record.
* Edit - User or Group can view and edit the record.
The value in this field sets what kind of access the User or Group has to the record and must be set to an access level that is at least equal to, or less restrictive than, the organization's default access level for the object/entity in question. Remember that sharing rules are meant to extend access; you would not use them to restrict access.
- If the org wide default access for Cases is Public Read/Write, that means that anyone can edit a Case. In this scenario creating sharing rules would not make sense because all users already have Read/Write access to all Cases. You would not create a rule to set access to Read (more restrictive access) for a sub-set of users.
- If instead the org wide default access for Cases is Private, you can use sharing rules to open up access (Read or Read/Write) to other users or groups.
After preparing your .csv data file, use the Data Loader to insert (create) records in the appropriate sharing table, such as Account Share, Case Share, Lead Share or Opportunity Share. You can access these by clicking on the "Show all Salesforce objects" checkbox in the Data Loader at the step where you select data objects.
Your new sharing rule entry will appear as a "Manual" sharing rule, as if it was created by clicking the "Share" button on the record directly in Salesforce.
Note the following behaviors on sharing object availability for custom objects in the Data Loader:
- Similar to standard objects, the sharing objects for custom objects are not available if its org wide default access is set to Public Read/Write.
- A sharing rule object is created for each custom object if it does not have a master-detail relationship to another object.
- The user creating the custom object must have the “Manage Sharing” permission in order for a sharing rule object to be automatically created for it.
Custom objects that meet the criteria above are available for selection in the Data Loader and appear in the "Show all Salesforce objects" view as: Share: CustomObjectName (CustomObjectName__Share)
SOAP API Developer's Guide: Custom Objects - Sharing and Custom Objects