SObjectAccessDecision クラス
Security.stripInaccessible メソッドへの呼び出しの結果と、それらの結果を取得するためのメソッドが含まれています。
名前空間
SObjectAccessDecision のメソッド
SObjectAccessDecision のメソッドは次のとおりです。
getModifiedIndexes()
stripInaccessible メソッドで変更された sObject のインデックスを返します。
署名
public Set<Integer> getModifiedIndexes()
例
この例では、ユーザーにアカウントの 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()
使用方法
stripInaccessible メソッドは、現在のユーザー操作のコンテキストでソースレコードへの項目レベルのアクセス権チェックを実行します。getRecords() メソッドは、現在のユーザーがアクセスできる項目のみを含んだ新しいレコードを返します。
署名
public List<SObject> getRecords()
例
この例では、ユーザーにアカウントの 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()
署名
public Map<String,Set<String>> getRemovedFields()
戻り値
例
この例では、ユーザーにアカウントの 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());