Allow Users to See Records Based on a Custom Field

This restriction rule allows high-volume users to see only the contracts where the user's department matches the contract's department. This rule uses a custom field, Department__c, that must have the appropriate value set through Apex, Process Builder, workflows, or flows.

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

Important

Available in: Lightning Experience in Enterprise, Performance, Unlimited, and Developer Editions

Tooling API

{
    "FullName":"Contract restriction rule for Customer Community",
    "Metadata": {
        "active":true,
        "description":"Show high-volume user by department",
        "enforcementType":"Restrict",
        "masterLabel":"RR for Internal Contracts",
        "recordFilter":"Department__c = $User.Department",
        "targetEntity":"Contract",
        "userCriteria":"$User.UserType = 'CSPLitePortal'",
        "version":1 
    } 
}

Metadata API

<?xml version="1.0" encoding="UTF-8"?>
<RestrictionRule xmlns="http://soap.sforce.com/2006/04/metadata">
    <active>true</active>
    <description>Show high-volume user by department</description>
    <enforcementType>Restrict</enforcementType>
    <masterLabel>RR for Internal Contracts</masterLabel>
    <recordFilter>Department__c = $User.Department</recordFilter>
    <targetEntity>Contract</targetEntity>
    <userCriteria>$User.UserType = 'CSPLitePortal'</userCriteria>
    <version>1</version>
</RestrictionRule>