Skip to main content

FIELD-LEVEL SECURITY

For more details check Check SOQL API - FIELD-LEVEL SECURITY and Advanced - FIELD-LEVEL SECURITY

NOTE! 🚨 All examples use inline queries built with the SOQL Lib Query Builder. If you are using a selector, replace SOQL.of(...) with YourSelectorName.query().

WITH USER_MODE​

USER_MODE is a default option.

SOQL

SELECT Id
FROM Account
WITH USER_MODE

SOQL Lib

SOQL.of(Account.SObjectType)
.toList();

or explicity:

SOQL.of(Account.SObjectType)
.userMode()
.toList();

WITH SYSTEM_MODE​

You can set SYSTEM_MODE for all queries by adding .systemMode() to selector class.

SOQL

SELECT Id
FROM Account
WITH SYSTEM_MODE

SOQL Lib

SOQL.of(Account.SObjectType)
.systemMode()
.toList();

stripInaccessible​

USER_MODE enforces not only object and field-level security but also sharing rules (with sharing). You may encounter situations where you need object and field-level security but want to ignore sharing rules (without sharing). To achieve this, use .systemMode(), .withoutSharing() and .stripInaccessible().

SOQL

SELECT Id
FROM Account
WITH SYSTEM_MODE

SOQL Lib

SOQL.of(Account.SObjectType)
.systemMode()
.withoutSharing()
.stripInaccessible()
.toList();