Create the Restriction Rule Using the Metadata API
Create a restriction rule that controls which tasks members of the Sales Team can access using the RestrictionRule Metadata API type.
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.
| Required Editions |
|---|
| Available in: Lightning Experience in Enterprise, Performance, Unlimited, and Developer Editions |
| User Permissions Needed | |
|---|---|
| To create and manage restriction rules: | Manage Sharing |
| To view restriction rules: | View Setup & Configuration AND View Restriction and Scoping Rules |
You can create up to two restriction rules per object in Enterprise and Developer Editions and up to five restriction rules per object in Performance and Unlimited Editions.
-
Set up the
package.xmlmanifest file and your directory.Example
package.xmlfile:Example directory:
-
Include all required fields. For more information, see the reference topic RestrictionRule.
For our example, we set the fields as follows:
-
Zip your directory and deploy your changes. For more information, see Deploying and Retrieving Metadata in the Metadata API Developer Guide.
-
Note the ID returned for the newly created restriction rule for later reference.
-
Retrieve and Update Information
Use the deploy() and retrieve() calls to move metadata (XML files) between a Salesforce organization and a local file system.