Newer Version Available

This content describes an older version of this product. View Latest

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.

This feature is a Beta Service. Customer may opt to try such Beta Service in its sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms.

Note

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.

  1. 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.
  2. 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}
  3. Use a POST request to create the restriction rule.
    POST /services/data/v52.0/tooling/sobjects/RestrictionRule
  4. Copy your restriction rule definition into the request body.
  5. Execute your request. Note the ID returned for the newly created restriction rule for later reference.