Newer Version Available
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.
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.xml manifest file and your
directory.
Example package.xml file:
1<?xml version="1.0" encoding="UTF-8"?> 2<Package xmlns="http://soap.sforce.com/2006/04/metadata"> 3 <types> 4 <members>*</members> 5 <name>RestrictionRule</name> 6 </types> 7 <version>52.0</version> 8</Package>Example directory:
1myPackage/package.xml 2myPackage/restrictionRules 3myPackage/restrictionRules/Rule1.rule 4myPackage/restrictionRules/Rule2.rule -
Include all required fields. For more information, see the reference topic RestrictionRule.
For our example, we set the fields as follows:
1<?xml version="1.0" encoding="UTF-8"?> 2<RestrictionRule xmlns="http://soap.sforce.com/2006/04/metadata"> 3 <active>true</active> 4 <description>Sales team can see only task records with specified record type</description> 5 <enforcementType>Restrict</enforcementType> 6 <masterLabel>Sales Team Record Type</masterLabel> 7 <recordFilter>recordTypeId = '011xxxxxxxxxxxx'</recordFilter> 8 <targetEntity>Task</targetEntity> 9 <userCriteria>$User.ProfileId = '00exxxxxxxxxxxx'</userCriteria> 10 <version>1</version> 11</RestrictionRule> - 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.