Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
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:
1{ 2 "FullName": "restrictionrulesalesteam", 3 "Metadata": { 4 "active": true, 5 "description": "Sales team can see only task records with specified record type", 6 "enforcementType": "Restrict", 7 "masterLabel": "Sales Team Record Type", 8 "recordFilter": "recordTypeId = '011xxxxxxxxxxxx'", 9 "targetEntity": "Task", 10 "userCriteria": "$User.ProfileId = '00exxxxxxxxxxxx'", 11 "version": 1 12 } 13} -
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.