← All articles
Action requiredSummer '26Platform / Apex

Action Required: Make Apex Access Modes Explicit Before API 67

API 67 changes Apex database and sharing defaults. Audit class and trigger access intent before setting versions to 67.0 so queries and DML don’t lose access or fail unexpectedly.

Required action

Before setting an existing Apex class or trigger to API 67.0 or later—or creating new Apex metadata at that version—make the intended record-sharing and database access mode explicit, then test with representative users. These changes depend on API version, not a date-based Release Update. Existing components generally keep their prior behavior until their API version is set to 67.0 or later. One exception: a class without an explicit sharing declaration defaults to with sharing if any class in its inheritance chain is saved at API 67.0 or later.[1][2][3][5]

Why the version bump matters

At API 67.0+, SOQL, SOSL, DML statements and Database methods default to user mode. These operations enforce the running user’s record sharing, object permissions and field-level security; a query can return fewer rows because of sharing or raise an access exception if the user lacks object or field access, and DML can fail where earlier system-mode code succeeded.[2][4]

The operation's access mode is separate from the class's sharing declaration. User-mode operations override the containing class's sharing declaration; for system-mode operations, the class's sharing declaration determines record-level sharing.[2]

Classes without an explicit sharing declaration default to with sharing at API 67.0+. Before API 67.0, the general default was without sharing, with exceptions; for example, a class that isn't an Apex entry point follows the calling class's sharing mode.[3]

The trigger’s execution context remains without sharing; database-operation access mode is a separate control. At API 67.0+, operations in trigger bodies default to user mode, which overrides the trigger’s sharing context.[2][5]

WITH SECURITY_ENFORCED no longer compiles at API 67.0+. Replace it with WITH USER_MODE; user mode also checks the WHERE clause and polymorphic fields and reports all field-access errors.[4]

Upgrade checklist

  1. Inventory Apex classes and triggers whose API version will be raised to 67.0, plus newly created components at API 67.0 or later. Check component apiVersion values and, in Salesforce DX projects, sourceApiVersion in sfdx-project.json.[3][5][6]
  2. For each query or DML operation, including those in trigger handlers, choose user or system mode deliberately. Use WITH USER_MODE / WITH SYSTEM_MODE for SOQL or SOSL, as user / as system for DML, or an explicit access level for Database methods.[2]
  3. Replace every WITH SECURITY_ENFORCED clause before compiling at API 67.0.[4]
  4. Add an explicit sharing declaration (with sharing, without sharing, or inherited sharing) to each class. Audit each inheritance chain as a unit because of the inheritance exception described above.[3]
  5. Run tests as users with different object, field and record access. Confirm restricted users see only intended records and that required system-mode jobs still work.

Do not change every operation to system mode just to make tests pass. Preserve the security behavior the feature actually requires, and document intentional exceptions.

Sources

  1. Summer '26 Apex Release Noteshttps://help.salesforce.com/s/articleView?id=release-notes.rn_apex.htm&language=en_US&release=262&type=5
  2. Database Operations Run in User Mode by Defaulthttps://help.salesforce.com/s/articleView?id=release-notes.rn_apex_default_user_mode.htm&language=en_US&release=262&type=5
  3. Apex Classes Enforce Sharing Rules by Defaulthttps://help.salesforce.com/s/articleView?id=release-notes.rn_apex_default_enforce_sharing.htm&language=en_US&release=262&type=5
  4. The WITH SECURITY_ENFORCED SOQL Clause Is Removedhttps://help.salesforce.com/s/articleView?id=release-notes.rn_apex_removed_withSecurityEnforced.htm&language=en_US&release=262&type=5
  5. Apex Triggers Always Run in a without sharing Contexthttps://help.salesforce.com/s/articleView?id=release-notes.rn_apex_triggers_system_mode.htm&language=en_US&release=262&type=5
  6. Salesforce CLI template generate project commandhttps://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_template_generate_project.html