Create a Restriction Rule Using the Tooling API
Create a restriction rule that controls which tasks members of the Sales Team can access
using the RestrictionRule Tooling API object.
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 a value for the FullName value (the full name of the associated metadata object in Metadata API). We don't support two consecutive underscores in the FullName field.
-
Include all other required fields. For more information, see the reference topic RestrictionRule.
For our example, we set the fields as follows:
{ "FullName": "restrictionrulesalesteam", "Metadata": { "active": true, "description": "Sales team can see only task records with specified record type", "enforcementType": "Restrict", "masterLabel": "Sales Team Record Type", "recordFilter": "recordTypeId = '011xxxxxxxxxxxx'", "targetEntity": "Task", "userCriteria": "$User.ProfileId = '00exxxxxxxxxxxx'", "version": 1 } }
-
Use a POST request to create the restriction rule.
POST /services/data/v55.0/tooling/sobjects/RestrictionRule
- Copy your restriction rule definition into the request body.
- Execute your request. Note the ID returned for the newly created restriction rule for later reference.