Skip to content

release/v3.2.4

Compare
Choose a tag to compare
@pgajek2 pgajek2 released this 01 Jul 06:57
· 1 commit to main since this release
32645c1

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();