Newer Version Available

This content describes an older version of this product. View Latest

CriteriaBasedSharingRule

This component is removed as of API version 33.0 and is available in earlier versions only. Use SharingRules instead. Represents a criteria-based sharing rule. CriteriaBasedSharingRule enables you to share records based on specific criteria.

It extends the BaseSharingRule metadata type and inherits its sharedTo field. For more information, see “Criteria-Based Sharing Rules Overview” in the Salesforce online help.

You can’t create a CrteriaBasedSharingRule component directly. Use the child components instead.

Note

Declarative Metadata File Suffix and Directory Location

CriteriaBasedSharingRule components are stored within the SharingRules component in the criteriaBasedRules field.

Version

CriteriaBasedSharingRule components are available in API version 24.0 and later.

Fields

The following information assumes that you are familiar with implementing sharing rules for standard objects and custom objects. For more information on these fields, see “Sharing Settings” in the Salesforce online help.

Field Field Type Description
criteriaItems FilterItem[] List that represents the criteria for the sharing rule. The possible values are:
  • field
  • operation
  • value

AccountCriteriaBasedSharingRule

Represents a criteria-based sharing rule for accounts. It extends the CriteriaBasedSharingRule metadata type and inherits its criteriaItems field.

AccountCriteriaBasedSharingRule is used by the criteriaBasedRules field in AccountSharingRules.

Field Field Type Description
accountAccessLevel ShareAccessLevelNoNone (enumeration of type string) Required. A value that represents the level of access that the user or group has to the account. The possible values are:
  • Read
  • Edit
  • All
booleanFilter string Represents the filter logic of the sharing rule.
caseAccessLevel ShareAccessLevelNoAll (enumeration of type string) Required. A value that represents the level of access that the user or group has to cases associated with the account. The possible values are:
  • None
  • Read
  • Edit
contactAccessLevel ShareAccessLevelNoAll (enumeration of type string) Required. A value that represents the level of access that the user or group has to contacts associated with the account. The possible values are:
  • None
  • Read
  • Edit
description string Represents the description of the sharing rule. Maximum of 1000 characters.

This field is available in API version 29.0 and later.

name string Required. Name for the sharing rule. Corresponds to Label in the user interface.
opportunityAccessLevel ShareAccessLevelNoAll (enumeration of type string) Required. A value that represents the level of access that a target group is granted for any associated opportunity. The possible values are:
  • None
  • Read
  • Edit

CampaignCriteriaBasedSharingRule

Represents a criteria-based sharing rule for campaigns. It extends the CriteriaBasedSharingRule metadata type and inherits its criteriaItems field.

CampaignCriteriaBasedSharingRule is used by the criteriaBasedRules field in CampaignSharingRules.

Field Field Type Description
booleanFilter string Represents the filter logic of the sharing rule.
description string Represents the description of the sharing rule. Maximum of 1000 characters.

This field is available in API version 29.0 and later.

campaignAccessLevel ShareAccessLevelNoNone (enumeration of type string) Required. A value that represents the level of access that a target group is granted for a campaign. The possible values are:
  • Read
  • Edit
  • All
name string Required. Name for the sharing rule. Corresponds to Label in the user interface.

CaseCriteriaBasedSharingRule

Represents a criteria-based sharing rule for cases. It extends the CriteriaBasedSharingRule metadata type and inherits its criteriaItems field.

CaseCriteriaBasedSharingRule is used by the criteriaBasedRules field in CaseSharingRules.

Field Field Type Description
booleanFilter string Represents the filter logic of the sharing rule.
description string Represents the description of the sharing rule. Maximum of 1000 characters.

This field is available in API version 29.0 and later.

caseAccessLevel ShareAccessLevelReadEdit (enumeration of type string) Required. A value that represents the level of access being granted for a case. The possible values are:
  • Read
  • Edit
name string Required. Name for the sharing rule. Corresponds to Label in the user interface.

ContactCriteriaBasedSharingRule

Represents a criteria-based sharing rule for contacts. It extends the CriteriaBasedSharingRule metadata type and inherits its criteriaItems field.

ContactCriteriaBasedSharingRule is used by the criteriaBasedRules field in ContactSharingRules.

Field Field Type Description
booleanFilter string Represents the filter logic of the sharing rule.
description string Represents the description of the sharing rule. Maximum of 1000 characters.

This field is available in API version 29.0 and later.

contactAccessLevel ShareAccessLevelReadEdit (enumeration of type string) Required. A value that represents the level of access being granted to the target group, role, or user for a contact. The possible values are:
  • Read
  • Edit
name string Required. Name for the sharing rule. Corresponds to Label in the user interface.

LeadCriteriaBasedSharingRule

Represents a criteria-based sharing rule for leads. It extends the CriteriaBasedSharingRule metadata type and inherits its criteriaItems field.

LeadCriteriaBasedSharingRule is used by the criteriaBasedRules field in LeadSharingRules.

Field Field Type Description
booleanFilter string Represents the filter logic of the sharing rule.
description string Represents the description of the sharing rule. Maximum of 1000 characters.

This field is available in API version 29.0 and later.

leadAccessLevel ShareAccessLevelReadEdit (enumeration of type string) Required. A value that represents the level of allowed access. The possible values are:
  • Read
  • Edit
name string Required. Name for the sharing rule. Corresponds to Label in the user interface.

OpportunityCriteriaBasedSharingRule

Represents a criteria-based sharing rule for opportunities. It extends the CriteriaBasedSharingRule metadata type and inherits its criteriaItems field.

OpportunityCriteriaBasedSharingRule is used by the criteriaBasedRules field in OpportunitySharingRules.

Field Field Type Description
booleanFilter string Represents the filter logic of the sharing rule.
description string Represents the description of the sharing rule. Maximum of 1000 characters.

This field is available in API version 29.0 and later.

opportunityAccessLevel ShareAccessLevelReadEdit (enumeration of type string) Required. A value that represents the level of allowed access. The possible values are:
  • Read
  • Edit
name string Required. Name for the sharing rule. Corresponds to Label in the user interface.

CustomObjectCriteriaBasedSharingRule

Represents a criteria-based sharing rule for custom objects. It extends the CriteriaBasedSharingRule metadata type and inherits its criteriaItems field.

CustomObjectCriteriaBasedSharingRule is used by the criteriaBasedRules field in CustomObjectSharingRules.

Field Field Type Description
accessLevel string Required. A value that represents the type of allowed sharing. The possible values are:
  • Read
  • Edit
  • All
booleanFilter string Represents the filter logic of the sharing rule.
description string Represents the description of the sharing rule. Maximum of 1000 characters.

This field is available in API version 29.0 and later.

name string Required. Name for the sharing rule. Corresponds to Label in the user interface.

UserCriteriaBasedSharingRule

Represents a criteria-based sharing rule for users. It extends the CriteriaBasedSharingRule metadata type and inherits its criteriaItems field.

UserCriteriaBasedSharingRule is used by the criteriaBasedRules field in UserSharingRules.

Field Field Type Description
booleanFilter string Represents the filter logic of the sharing rule.
description string Represents the description of the sharing rule. Maximum of 1000 characters.

This field is available in API version 29.0 and later.

name string Required. Name for the sharing rule. Corresponds to Label in the user interface.
userAccessLevel ShareAccessLevelReadEdit (enumeration of type string) Required. A value that represents the type of allowed sharing. The possible values are:
  • Read
  • Edit

Declarative Metadata Sample Definition

The following is the definition of two owner-based sharing rules and one criteria-based sharing rule containing two criteria items. The file name corresponds to the Account.sharingRules file under the accountSharingRules directory.

1<?xml version="1.0" encoding="UTF-8"?>
2<AccountSharingRules xmlns="http://soap.sforce.com/2006/04/metadata">
3  <ownerRules>
4    <fullName>G1Dev_G2New</fullName>
5    <sharedTo>
6      <group>G2New</group>
7    </sharedTo>
8    <sharedFrom>
9      <group>G1Dev</group>
10    </sharedFrom>
11    <accountAccessLevel>Read</accountAccessLevel>
12    <caseAccessLevel>None</caseAccessLevel>
13    <contactAccessLevel>Read</contactAccessLevel>
14  </ownerRules>
15    <fullName>G2New_R1New</fullName>
16    <sharedTo>
17      <roleAndSubordinates>R1New</roleAndSubordinates>
18    </sharedTo>
19    <sharedFrom>
20      <group>G2New</group>
21    </sharedFrom>
22    <accountAccessLevel>Edit</accountAccessLevel>
23    <caseAccessLevel>Read</caseAccessLevel>
24    <contactAccessLevel>Edit</contactAccessLevel>
25    <name>G2New_R1New</name>
26    <opportunityAccessLevel>None</opportunityAccessLevel>
27  </ownerRules>
28  <criteriaBasedRules>
29    <fullName>AccountCriteria</fullName>
30    <sharedTo>
31      <group>G1</group>
32    </sharedTo>
33    <criteriaItems>
34      <field>BillingCity</field>
35      <operation>equals</operation>
36      <value>San Francisco</value>
37    </criteriaItems>
38    <criteriaItems>
39      <field>MyChkBox__c</field>
40      <operation>notEqual</operation>
41      <value>False</value>
42    </criteriaItems>
43    <accountAccessLevel>Read</accountAccessLevel>
44    <booleanFilter>1 OR 2</booleanFilter>
45    <caseAccessLevel>None</caseAccessLevel>
46    <contactAccessLevel>Read</contactAccessLevel>
47    <name>AccountCriteria</name>
48    <opportunityAccessLevel>None</opportunityAccessLevel>
49  </criteriaBasedRules>
50</AccountSharingRules>