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 Metadata API type.
| Required Editions |
|---|
| 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 |
note: You can use the RestrictionRule object to create and manage both restriction rules and scoping rules. For information on restriction rules, see the Restriction Rule Developer Guide.
-
Set up the
package.xmlmanifest file and your directory.Example
package.xmlfile:<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>*</members> <name>RestrictionRule</name> </types> <version>68.0</version> </Package>Example directory:
myPackage/package.xml myPackage/restrictionRules myPackage/restrictionRules/Rule1.rule myPackage/restrictionRules/Rule2.rule -
Include all required fields. For more information, see the reference topic RestrictionRule.
In this example, we used these values.
<?xml version="1.0" encoding="UTF-8"?> <RestrictionRule xmlns="http://soap.sforce.com/2006/04/metadata"> <active>true</active> <description>Sales support associate sees only account records of specified advisor</description> <enforcementType>Scoping</enforcementType> <masterLabel>Advisor1 Record Type</masterLabel> <recordFilter>recordTypeId = '012xxxxxxxxxxxx'</recordFilter> <targetEntity>Account</targetEntity> <userCriteria>$User.ProfileId = '00exxxxxxxxxxxx'</userCriteria> <version>1</version> </RestrictionRule> -
Zip your directory, and deploy your changes. For more information, see Deploying and Retrieving Metadata in the Metadata API Developer Guide.