release/v3.2.4
01-July-2024
New
userMode()
- API Update 61.0
userMode
Execution mode in which the object permissions, field-level security, and sharing rules of the current user are enforced.
By default, all queries are executed WITH USER_MODE
. However, developers can override this. For more details, check Field-Level Security and Sharing Rules.
The userMode()
method can be useful to override the systemMode()
provided by the selector as in the example below.
Signature
Queryable userMode()
Example
public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selector {
public static final String MOCK_ID = 'SOQL_Account';
public static SOQL_Account query() {
return new SOQL_Account();
}
private SOQL_Account() {
super(Account.SObjectType);
// default settings
with(Account.Id, Account.Name, Account.Type);
systemMode();
withoutSharing();
mockId(MOCK_ID);
}
}
SOQL_Account.query()
.userMode() // systemMode() from SOQL_Account.query will be overridden by userMode() method
.toList();