Newer Version Available
Create a Scoping Rule Using the Tooling API
Create a scoping rule that shows a sales support associate who supports multiple
financial advisors only the record set that corresponds to the financial advisor that the
associate is working with. Use the RestrictionRule Tooling API object.
| Available in: Lightning Experience in Performance and Unlimited Editions |
| User Permissions Needed | |
|---|---|
| To create and manage scoping rules: | Manage Sharing |
| To view scoping rules: | View Setup & Configuration AND View Restriction and Scoping Rules |
This example uses the SOQL operator in the recordFilter field to determine which accounts
to display to the user based on the account, team, and user entitlements.
- Set a value for the FullName value (the full name of the associated metadata object in Metadata API).
-
Include all other required fields. For more information, see the reference topic RestrictionRule.
In this example, we used these values.
1{ 2 "FullName": "SalesSupportAssociateScopingRule", 3 "Metadata": { 4 "active": true, 5 "description": "Sales support associate sees only account records of of Advisor1", 6 "enforcementType": "Scoping", 7 "masterLabel": "Advisor1 Record Set", 8 "recordFilter": "SOQL(id, SELECT Account__c FROM Client_Entitlement__c USING SCOPE EVERYTHING 9 WHERE Team_Entitlement__c IN ( 10 SELECT Team_Entitlement__c 11 FROM User_Entitlement__c 12 USING SCOPE EVERYTHING 13 WHERE User__c = $User.id) 14 )", 15 "targetEntity": "Account", 16 "userCriteria": "$User.ProfileId = '00exxxxxxxxxxxx'", 17 "version": 1 18 } 19} -
Use a POST request to create the scoping rule.
POST /services/data/v53.0/tooling/sobjects/RestrictionRule
- Copy your scoping rule definition into the request body.
- Execute your request. Copy the ID returned for the scoping rule for later reference.