Ir al contenido

Study guide

Esta página aún no está disponible en tu idioma.

Study guide for chapter 17 of the Securing Salesforce: Sharing and Visibility course. Read the seven modules first; this page helps you check what stuck.

About this study guide. It’s built only from this course’s own content and the published Salesforce exam guide’s list of objectives. It is never based on real exam questions, and it doesn’t claim to know what’s on the exam. If you’ve taken the exam, please don’t send me questions from it: the certification agreement forbids sharing them, and memorizing answers is the wrong way to become an architect anyway.

This chapter teaches one objective from the section Permissions to Standard Objects, Custom Objects, and Fields (27% of the exam): programmatic enforcement of security settings. The exam guide’s list of skills also names the risks of “run in context” tools exposing aggregate data, which is exactly what a system-mode roll-up or count can do. The exam guide aligns to Winter ‘23, and this area changed more than any other since then, so the changes are in their own dated list. Know both, and know which date each belongs to.

Tick them off as you go. Each one links to where it’s taught.

Two settings (supports OBJ-5)

  • I know the sharing keyword decides which records, and the access mode of each operation decides objects and fields. (Two questions, two settings)
  • I know user mode enforces the user’s sharing, object permissions and field-level security; system mode checks no objects or fields and leaves records to the class’s keyword. (Where the two settings meet)
  • I know sharing declarations don’t enforce object-level access or field-level security. (The three keywords)

Sharing keywords (supports OBJ-5)

  • I know with sharing (the default to use), without sharing (targeted elevation, with caution) and inherited sharing (the caller’s mode, for shared service code). (The three keywords)
  • I know the entry points: Aura controllers, @AuraEnabled methods called from Lightning web components, Visualforce controllers, Apex REST services and async Apex; and that inherited sharing runs with sharing as an entry point. (Entry points)
  • I know a method’s sharing mode comes from where it’s defined, not where it’s called (except in inherited sharing); inner classes keep their own; a class with no keyword that extends another adopts its mode; async starts over. (Does it flip back and forth?)
  • I know a guest-executable @AuraEnabled method should always use with sharing. (Entry points)

User mode and system mode (supports OBJ-5)

  • I know the three forms: WITH USER_MODE / WITH SYSTEM_MODE on queries, as user / as system on DML, and AccessLevel.USER_MODE / SYSTEM_MODE on Database and Search methods. (How you ask for it)
  • I know user mode always respects sharing, whatever the class’s keyword. (What user mode checks)
  • I know what user mode reports: getInaccessibleFields() on a query, getDmlFieldNames() on a save, and SaveResult field errors on Database methods. (When it says no)

Checking permissions yourself (supports OBJ-5)

  • I know the choice: fail (user mode, naming the field), leave it out (stripInaccessible) or ask first (describe calls). (Fail, or leave it out?)
  • I know Security.stripInaccessible removes fields the user can’t access for an AccessType (create, read, update, upsert), from results, before DML and from untrusted input; never strips the ID; doesn’t support AggregateResult; and handles fields, not records. (stripInaccessible)
  • I know the describe calls: isAccessible, isCreateable, isUpdateable, and isDeletable on the object. (Describe calls)
  • I know the limits: Experience Cloud personal information settings aren’t enforced in Apex, the Automated Process user needs permission sets for these checks, and object and field permissions take precedence over sharing rules. (What none of them enforce)

Triggers and flows (supports OBJ-5)

  • I know triggers always run without sharing and can’t declare a keyword; delegate logic to handler classes with explicit modes. (Outside: always without sharing)
  • I know a flow’s default context comes from how it’s launched: screen flows, sites, buttons, Lightning pages and the REST API as the user; record-triggered, schedule-triggered and platform event–triggered flows in system context without sharing. (Who the flow runs as)
  • I know the run options, that System Context with Sharing skips object and field permissions, and that a user-context flow can inherit system context from its caller. (The four run options)
  • I know Run Flows is an app permission, system-triggered flows don’t need it, and access can be limited per flow by profile or permission set. (Who may run a flow)

Reviewing code (supports OBJ-5)

  • I know what to check: an explicit keyword on every class, an explicit mode on every operation, a reason for every use of system mode, fields stripped or checked, triggers delegating, flow run context deliberate, and tests as real users. (The checklist)
  • I know restriction rules aren’t applied to code running in system mode. (The system-mode inventory)
  • I know a static scanner can find a missing sharing declaration but can’t judge whether without sharing is justified. (What tools can find)

What changed since the exam’s Winter ‘23 alignment (dated, beyond the exam today)

  • I know that from Summer ‘26 (API version 67.0), classes with no keyword default to with sharing and database operations to user mode; that the change is versioned per class and trigger; and that Salesforce recommends always writing both. (The old default, and the new one)
  • I know WITH SECURITY_ENFORCED doesn’t compile at API 67.0 and later, and why user mode replaced it: polymorphic fields, every clause including WHERE, every FLS error, getInaccessibleFields(). (Why WITH SECURITY_ENFORCED went away)
  • I know that from API 67.0 the database operations inside a trigger body run in user mode unless system mode is explicit, effectively with sharing inside the trigger. (Inside: user mode)
  • I know Winter ‘27 (API version 68.0) added User Context—Enforces User Permissions, for screen and autolaunched flows, so a flow keeps the user’s access even when its caller runs in system context. (The four run options)

The exam is the floor, not the ceiling. These are the habits from this chapter that an architect needs, whether or not a question ever asks about them.

  • Write the keyword and the mode, even where the default is already right; the next reader shouldn’t need the API version.
  • Elevate narrowly: one method, one reason, and an answer back rather than records.
  • Strip anything built from a request, a screen, an integration or an agent before it’s saved.
  • Make every mode explicit before raising a version, then test as the least-privileged users.
  • Run screen flows as the user, and put any elevated step in a small subflow.
  • Keep the system-mode inventory, with who each row runs for and who it was tested as.
  • Let the scanner find missing decisions, and let a person judge the ones that are there.
TermIn one line
with sharingThe class enforces the running user’s sharing
without sharingThe class ignores the running user’s sharing
inherited sharingThe class takes the sharing mode of its caller
Entry pointWhere a transaction starts: a controller, a REST service, async Apex
User modeAn operation enforces the user’s sharing, object permissions and field-level security
System modeAn operation skips object and field checks; records follow the class’s keyword
Security.stripInaccessibleRemoves the fields a user can’t access from records, for one kind of operation
Describe callA schema check such as isAccessible or isUpdateable, made before doing work
Run contextWhether a flow runs as the user or in system context, with or without sharing
Run FlowsThe app permission that lets a user run flows directly
System-mode inventoryThe project’s list of everything that runs with more access than its user

Short scenarios in the style of the course. Decide your answer before you open it.

1. A with sharing class runs a query WITH SYSTEM_MODE. Which records and which fields come back?

The user’s records, because system mode leaves the records question to the class’s with sharing keyword; but every field, because system mode skips field-level security. Reread Where the two settings meet.

2. A without sharing class runs a query WITH USER_MODE. Does the user see records their sharing hides?

No. User mode always respects the user’s sharing, and overrides the class’s keyword. Reread What user mode checks.

3. One service class is called by a user-facing page and by a nightly job that must see every record. Which keyword does it get?

Inherited sharing: it takes the caller’s mode, with sharing for the page and without for the job. Make sure it’s safe to run in both. Reread Shared code: inherited sharing.

4. A site needs to tell a customer whether a delivery slot is full, which means counting every customer's orders. How do you build it without exposing those orders?

A small without sharing class with one method that counts the orders in system mode and returns only the number, called from a with sharing entry point, with the reason written beside it. That’s the “run in context” risk handled: an aggregate, on purpose, and nothing more. Reread Narrow elevation.

5. A table must show one column only to users who can read that field, and must not fail for everyone else. User mode or stripInaccessible?

stripInaccessible with AccessType.READABLE: it leaves the field out for users who can’t read it. User mode would fail the whole query. Reread Fail, or leave it out?

6. An Apex REST service builds a record from the request body and saves it. What should happen first?

Strip it with Security.stripInaccessible for the operation (create or update), so the caller can’t set a field they aren’t allowed to. Reread stripInaccessible.

7. A team raises a roll-up trigger from API 66.0 to 67.0, and the account totals drop for some users. Why, and what's the fix?

At 67.0 the queries inside the trigger body run in user mode, so they count only the orders the saving user can see. Make the roll-up’s query explicitly WITH SYSTEM_MODE in a handler, with its reason, and test as real users. Reread Why this catches teams.

8. A screen flow on a site set to the default context is called by a flow that runs in system context. Whose access does it run with, and how do you stop that?

It inherits system context from its caller. Set it to User Context—Enforces User Permissions (API 68.0 and later), or keep the caller in user context. Reread The four run options.

9. A restriction rule hides contracts from a team, but a custom page still lists them. What do you look for in the code?

System mode: a WITH SYSTEM_MODE query, or a query with no mode in a class saved before API 67.0. Restriction rules aren’t applied to code in system mode. Reread The system-mode inventory.

10. The code scanner passes a class that says without sharing and queries every account. Is the class approved?

Not yet. The scanner only checks that a sharing keyword is there; whether without sharing is right is a business question. Look for the reason beside it and its row in the inventory. Reread What tools can find.

The official list of objectives and their weights. Always check the current version before you book an exam.