Skip to main content

Field Level Security

USER_MODE is a default option. You can set SYSTEM_MODE for all queries by adding .systemMode() to selector class.

public inherited sharing class AccountSelector {

public static SOQL Query {
get {
return SOQL.of(Account.sObjectType)
.with(new List<sObjectField>{
Account.Id,
Account.Name
})
.systemMode(); //default FLS mode
}
}
}

public with sharing class MyController {

public static List<Account> getAccountInSystemMode() {
return AccountSelector.Query
.userMode() //override selector FLS mode
.asList();
}
}