この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

Newer Version Available

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

SObjectAccessDecision クラス

Security.stripInaccessible メソッドへの呼び出しの結果と、それらの結果を取得するためのメソッドが含まれています。

名前空間

System

SObjectAccessDecision のメソッド

SObjectAccessDecision のメソッドは次のとおりです。

getModifiedIndexes()

stripInaccessible メソッドで変更された sObject のインデックスを返します。

署名

public Set<Integer> getModifiedIndexes()

戻り値

型: Set<Integer>

変更された sObject の行インデックスを表す符号なし整数のセット。

この例では、ユーザにアカウントの AnnualRevenue 項目を更新する権限はありません。

1List<Account> accounts = new List<Account>{
2    new Account(Name='Account1', AnnualRevenue=1000),
3    new Account(Name='Account2')
4};
5
6// Strip fields that are not updatable
7SObjectAccessDecision decision = Security.stripInaccessible(
8    AccessType.UPDATABLE,
9    accounts);
10
11// Print stripped records
12for (SObject strippedAccount : decision.getRecords()) {
13    System.debug(strippedAccount);
14}
15
16// Print modified indexes
17System.debug(decision.getModifiedIndexes());

getRecords()

現在のユーザの項目レベルセキュリティチェックに失敗した項目が除外されている以外はソースレコードと同じ、新しい sObject のリストを返します。

使用方法

stripInaccessible メソッドは、現在のユーザ操作のコンテキストでソースレコードへの項目レベルのアクセス権チェックを実行します。getRecords() メソッドは、現在のユーザがアクセスできる項目のみを含んだ新しいレコードを返します。

署名

public List<SObject> getRecords()

戻り値

型: List<SObject>

結果リストに sObject が 1 つしか含まれていなくても、戻り型はリストです (サイズ 1)。

この例では、ユーザにアカウントの AnnualRevenue 項目を更新する権限はありません。

1List<Account> accounts = new List<Account>{
2    new Account(Name='Account1', AnnualRevenue=1000),
3    new Account(Name='Account2')
4};
5
6// Strip fields that are not updatable
7SObjectAccessDecision decision = Security.stripInaccessible(
8    AccessType.UPDATABLE,
9    accounts);
10
11// Print stripped records
12for (SObject strippedAccount : decision.getRecords()) {
13    System.debug(strippedAccount);
14}

getRemovedFields()

sObject 型と対応するアクセスできない項目の対応付けを返します。対応付けのキーは、sObject 型の文字列表現です。対応付けの値は、アクセスできない項目の名前を示す一連の文字列です。

署名

public Map<String,Set<String>> getRemovedFields()

戻り値

型: Map<String,Set<String>>

この例では、ユーザにアカウントの AnnualRevenue 項目を更新する権限はありません。

1List<Account> accounts = new List<Account>{
2    new Account(Name='Account1', AnnualRevenue=1000),
3    new Account(Name='Account2')
4};
5
6// Strip fields that are not updatable
7SObjectAccessDecision decision = Security.stripInaccessible(
8    AccessType.UPDATABLE,
9    accounts);
10
11// Print stripped records
12for (SObject strippedAccount : decision.getRecords()) {
13    System.debug(strippedAccount);
14}
15// Print removed fields
16System.debug(decision.getRemovedFields());