3. Summer’21新機能の中でこんなものが
Control Access to Sensitive
Records with Restriction Rules
(Now in Beta)
https://developer.salesforce.com/
blogs/2021/05/control-access-to-
sensitive-records-with-restriction-
rules-now-in-beta.html
→ Restriction Rules(制限ルー
ル)による機密レコードへのアク
セス制御
4. Summer’21新機能の中でこんなものが
Control Access to Sensitive
Records with Restriction Rules
(Now in Beta)
https://developer.salesforce.com/
blogs/2021/05/control-access-to-
sensitive-records-with-restriction-
rules-now-in-beta.html
→ Restriction Rules(制限ルー
ル)による機密レコードへのアク
セス制御
組織の標準設定 +
追加の共有
(共有ルール、手動共有)
左記の設定 -
制限ルール
5. Summer’21新機能の中でこんなものが
Control Access to Sensitive
Records with Restriction Rules
(Now in Beta)
https://developer.salesforce.com/
blogs/2021/05/control-access-to-
sensitive-records-with-restriction-
rules-now-in-beta.html
→ Restriction Rules(制限ルー
ル)による機密レコードへのアク
セス制御
組織の標準設定 +
追加の共有
(共有ルール、手動共有)
左記の設定 -
制限ルール
可視性の
「引き算」が
できる!?
6. もう少し調べてみた
Without restriction rules, users who have access to an account can see its contracts, tasks, and events,
even when the organization-wide default is set to Private. For custom objects, users can see all of their
child records. Restriction rules allow you to define which users see which records in Lightning
Experience for custom objects, contracts, tasks, and events and configure truly “Private” access for
these objects. Creating, editing, and deleting restriction rules are only available via the Tooling and
Metadata APIs.
7. もう少し調べてみた
Without restriction rules, users who have access to an account can see its contracts, tasks, and events,
even when the organization-wide default is set to Private. For custom objects, users can see all of their
child records. Restriction rules allow you to define which users see which records in Lightning
Experience for custom objects, contracts, tasks, and events and configure truly “Private” access for
these objects. Creating, editing, and deleting restriction rules are only available via the Tooling and
Metadata APIs.
• 適用できるオブジェクト
• Contract(契約)、task(ToDo)、event(行動)
• カスタムオブジェクト
• 組織のデフォルト共有設定が「非公開」であっても、これらのオブジェクトが子レコードになってい
る場合は無制限に参照可能になってしまう。
• →子レコードの中でも更に詳細な閲覧制限を実現したい場合に使用する
• 登録/更新/削除は以下の経路で行う
• Tooling API
• Metadata API
8. 設定方法①:Tooling API
Tooling API:JSON形式で定義を作成
→Tooling APIエンドポイントにPOSTで送る /services/data/v52.0/tooling/sobjects/RestrictionRule
{
"FullName":"restictionruleeventsrole",
"Metadata": {
"active":true,
"description":"Allows active users to see only events owned by users of the same role.",
"enforcementType":"Restrict",
"masterLabel":"Events Owned by Same Role",
"recordFilter": "Owner.RoleId = $User.UserRoleId",
"targetEntity":"Event",
"userCriteria":"$User.IsActive = true",
"version":1
}
}
9. 設定方法②:Metadata API
Metadata API:XML形式で定義ファイルを作成
<?xml version="1.0" encoding="UTF-8"?>
<RestrictionRule xmlns="http://soap.sforce.com/2006/04/metadata">
<active>true</active>
<description>Sales team can see only task records with specified record type</description>
<enforcementType>Restrict</enforcementType>
<masterLabel>Sales Team Record Type</masterLabel>
<recordFilter>recordTypeId = '011xxxxxxxxxxxx'</recordFilter>
<targetEntity>Task</targetEntity>
<userCriteria>$User.ProfileId = '00exxxxxxxxxxxx'</userCriteria>
<version>1</version>
</RestrictionRule>
→package.xmlとともにデプロイ
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>restrictionRules</members>
<name>RestrictionRule</name>
</types>
<version>52.0</version>
</Package>
11. 想定されるユースケースとサンプル①
• Allow Users to See Only Specified Record Type
特定のレコードタイプのみ表示される
• recordFilter:RecordTypeId = ‘012xxxxxxxxxxxx’ (レコードタイプID)
• userCriteria:$User.RoleId = ‘00exxxxxxxxxxxx‘ (ユーザのロールID)
• Allow Users to See Only Records That They Own
所有者が自分であるレコードのみ表示される
• recordFilter:OwnerId = $User.Id (所有者のID = ユーザID)
• userCriteria:$User.ProfileId = ‘005xxxxxxxxxxxx’ (ユーザのプロファイルID)
• Allow Users to See Only Records Owned by Same Role
自分と同じロールの人が所有するレコードのみ表示される
• recordFilter:Owner.RoleId = $User.UserRoleId
(所有者のロールID = ユーザのロールID)
• userCriteria:$User.IsActive = true
(有効ユーザすべて)
12. 想定されるユースケースとサンプル②
• Allow Users to See Only Records Owned by Same Profile
自分と同じプロファイルの人が所有するレコードのみ表示される
• recordFilter:Owner.ProfileId = $User.ProfileId
(所有者のプロファイルID = ユーザのプロファイルID)
• userCriteria:$User.IsActive = true
(有効ユーザすべて)
• Allow Users to See Records Based on a Custom Field
カスタム項目の値を使った制御
• recordFilter:Department__c = $User.Department
(項目:Department__cの値 = ユーザの部署)
• userCriteria:$User.UserType = ‘CSPLitePortal’
(ユーザライセンスが「CSP Lite Portal」)