Apex with sharingの使い方のサンプル
環境
Salesforce Apex
構文
public with sharing class SharingTest
// 処理コードを記載
}
with sharingを使用した別のクラスから呼び出された場合、
そのクラスにもwith sharingが適用されます。
with sharingだとユーザモードでの実行となるため、共有ルールが適用されます。
使用例
public without sharing class SharingTest {
List<Account> accList {get; set;}
public SharingTest(){
}
public List<Account> getAccList(){
List<Account> result;
result = [SELECT Id,Name,Owner.Name
FROM Account
ORDER BY Owner.Name ASC
];
return result;
}
}