0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

APEX開発向上_002

Posted at

APEXクラス内、SOQL検索結果が共有設定/共有ルールより影響あり・なしのパターン:

パターン01:
public class AccountTriggerHandler {

   //取引先の共有設定が私有
   //実行ユーザより、検索結果がnullの場合あり
  List<Account> accList = [Select Id,Name From Account];
  
}

パターン02:
public with sharing class AccountTriggerHandler {

   //取引先の共有設定が私有
   //実行ユーザより、検索結果がnullの場合あり
  List<Account> accList = [Select Id,Name From Account];
  
}

パターン03:
public without sharing class AccountTriggerHandler {

   //取引先の共有設定が私有
   //検索結果が全組織のデータ
  List<Account> accList = [Select Id,Name From Account];
  
}

結論:
パターン01 と パターン02 が結果が一緒、共有設定が私有の場合、実行ユーザより、検索結果が変わる場合ある。
パターン03が共有設定が無視して、すべてのレコードを取得できる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?