---
schema_version: "1"
id: b2f312b881bc0ceedb50b5302a07b853700da27508b2f414fd70b6e8ef7c3f2b
title: RestrictionRule
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_restrictionrule.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_restrictionrule.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 12c873bb10845d87b0eb9b06157de60bd60d90e6f313ba85e081a28d3d3af81b
description: Represents a restriction rule or a scoping rule. A restriction rule has enforcementType set to Restrict and controls the access that specified users have to designated records. A scoping rule has enforcementType set to Scoping and controls the default records that your users see without restricting access. This type extends the Metadata metadata type and inherits its fullName field.
---
# RestrictionRule

Represents a restriction rule or a scoping rule. A restriction rule has enforcementType set to Restrict and controls the access that specified users have to designated records. A scoping rule has enforcementType set to Scoping and controls the default records that your users see without restricting access. This type extends the Metadata metadata type and inherits its fullName field.

![Important](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/images/icon_note_important.png)

#### Important

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

## File Suffix and Directory Location

RestrictionRule components have the suffix .rule and are stored in the restrictionRules folder.

## Version

RestrictionRule components are available in API version 52.0 and later.

## Special Access Rules

Only users with the View Restriction and Scoping Rules permission can view restriction rules and scoping rules via the API. Only users with the Manage Sharing permission can view, create, update, and delete restriction rules and scoping rules.

## Fields

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



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

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

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

            </tr>

          </thead>

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

              <td class="entry" headers="d826627e115" data-title="Field Type">boolean</td>

              <td class="entry" headers="d826627e118" data-title="Description">Indicates whether the rule is active (<samp class="codeph nolang">true</samp>) or not (<samp class="codeph nolang">false</samp>). The default
                value is <samp class="codeph nolang">false</samp>.</td>

            </tr>

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

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

              <td class="entry" headers="d826627e118" data-title="Description">Required. The description of the rule.</td>

            </tr>

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

              <td class="entry" headers="d826627e115" data-title="Field Type">EnforcementType (enumeration of type string)</td>

              <td class="entry" headers="d826627e118" data-title="Description">Required. The type of rule. Valid values are:<ul class="ul bulletList">
                  <li class="li">
                    <samp class="codeph nolang">FieldRestrict</samp>—Don’t use.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">Restrict</samp>—Restriction rule.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">Scoping</samp>—Scoping rule.
                  </li>

                </ul>
              </td>

            </tr>

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

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

              <td class="entry" headers="d826627e118" data-title="Description">Required. The name of the rule.</td>

            </tr>

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

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

              <td class="entry" headers="d826627e118" data-title="Description">Required. The criteria that determine which records are accessible via the
                rule.</td>

            </tr>

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

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

              <td class="entry" headers="d826627e118" data-title="Description">Required. The object for which you're creating the rule. We recommend that you
                don’t edit this field after the rule is created.<div class="p">If
                  <span class="keyword parmname">enforcementType</span> is set to <samp class="codeph nolang">Restrict</samp>, custom objects, external objects, and these objects are supported:<ul class="ul bulletList">
                    <li class="li">Contract</li>

                    <li class="li">Event</li>

                    <li class="li">Quote</li>

                    <li class="li">Task</li>

                    <li class="li">TimeSheet</li>

                    <li class="li">TimeSheetEntry</li>

                  </ul>
                </div>
                <div class="p">If <span class="keyword parmname">enforcementType</span> is set to <samp class="codeph nolang">Scoping</samp>, custom objects and these objects are
                  supported: <ul class="ul bulletList">
                    <li class="li">Account</li>

                    <li class="li">Case</li>

                    <li class="li">Contact</li>

                    <li class="li">Event</li>

                    <li class="li">Lead</li>

                    <li class="li">Opportunity</li>

                    <li class="li">Task</li>

                  </ul>
                </div>
              </td>

            </tr>

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

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

              <td class="entry" headers="d826627e118" data-title="Description">Required. The users that this rule applies to, such as all active users or
                users with a specified role or profile.</td>

            </tr>

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

              <td class="entry" headers="d826627e115" data-title="Field Type">int</td>

              <td class="entry" headers="d826627e118" data-title="Description">Required. The rule's version number.</td>

            </tr>

          </tbody>

        </table>

## Declarative Metadata Sample Definition

The following is an example of a RestrictionRule component representing a restriction rule.

<?xml version="1.0" encoding="UTF-8"?>
<RestrictionRule xmlns="http://soap.sforce.com/2006/04/metadata">
    <active\>true</active\>
    <description\>Allows users with a specific profile to see only tasks that they own.</description\>
    <enforcementType\>Restrict</enforcementType\>
    <masterLabel\>Tasks You Own</masterLabel\>
    <recordFilter\>OwnerId = $User.Id</recordFilter\>
    <targetEntity\>Task</targetEntity\>
    <userCriteria\>$User.ProfileId = '00exxxxxxxxxxxx'</userCriteria\>
    <version\>1</version\>
</RestrictionRule\>

The following is an example of a RestrictionRule component representing a scoping rule.

<?xml version="1.0" encoding="UTF-8"?>
<RestrictionRule xmlns="http://soap.sforce.com/2006/04/metadata">
    <active>true</active>
    <description>View tasks contacts from Department A.</description>
    <enforcementType>Scoping</enforcementType>
    <masterLabel>SR for Department A contacts</masterLabel>
    <recordFilter>Department=$User.Department</recordFilter>
    <targetEntity>Contact</targetEntity>
    <userCriteria>$User.UserRoleId = '00Exxxxxxxxxxxx'</userCriteria>
    <version>1</version>
</RestrictionRule>

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

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types\>
        <members\>\*</members\>
        <name\>RestrictionRule</name\>
    </types\>
    <version\>55.0</version\>
</Package\>