Package homePlatform Sharing and Visibility ArchitectStudy guide
Study guide

Chapter 127% of the exam60 min

Permissions to Standard Objects, Custom Objects, and Fields

How to give each user exactly the object and field access they need: profiles, permission sets, permission set groups and muting, object permissions from Read to Modify All, field-level security and View All Fields, why page layouts and visibility rules don't secure data, the controls that protect PCI, PII and health data, and how Apex, Lightning components, Visualforce and flows enforce security.

By the end of this chapter you can

  • Given a scenario, recommend the right level of object permissions needed to provide the appropriate access to a set of users
  • Given a scenario, recommend the correct level of field permissions needed to provide the appropriate access to a set of users
  • Given a scenario, recommend the appropriate mechanism to hide data at the user interface level
  • Given a scenario, determine the appropriate access controls to protect sensitive data (e.g. PCI, PII, or HIPAA)
  • Given a scenario, recommend the appropriate programmatic solution to ensure security settings are enforced

Object permissions

Scenario: A clinic network is moving to Salesforce. Receptionists book appointments, nurses update patient records, doctors read everything clinical, and billing staff handle payments. Each group needs different access to the same objects.

The four layers of access. 1, Org: who can log in, from where and when. 2, Objects: create, read, edit and delete, plus View All and Modify All. 3, Fields: field-level security makes fields hidden, read-only or editable. 4, Records: org-wide defaults, roles, sharing rules and teams. Objects and fields decide what users can do; sharing decides which records. 1. Org who can log in, from where and when 2. Objects create, read, edit, delete; View All, Modify All 3. Fields field-level security: hidden, read-only, editable 4. Records org-wide defaults, roles, sharing rules, teams Objects and fields decide what users can do; sharing decides which records
The four layers of access

Four layers of access

  1. Org: who can log in, from where and when: login hours, trusted IP ranges and password policies.
  2. Objects: what users can do with an object's records: create, read, edit, delete.
  3. Fields: which fields they can see and edit.
  4. Records: which records they can reach, through sharing.

Permissions apply in the API too, not just in the UI.

Object permissions

Permission Allows Needs
Read Viewing records the user can reach through sharing —
Create Creating records Read
Edit Editing records the user can reach Read
Delete Deleting records the user can reach Read and Edit
View All Viewing every record of the object, regardless of sharing Read
Modify All Editing, deleting and sharing every record of the object Read, Edit, Delete and View All

View All Data and Modify All Data apply to every object and override all sharing. Keep them for a few administrators and integration users.

Profiles, permission sets and groups

Tool What it is Use it for
Profile Each user has exactly one, tied to their licence Defaults: login hours, IP ranges, default apps, record types and page layout assignments
Permission set A collection of permissions; users can have many Granting object, field, app, Apex and system permissions for a task
Permission set group A bundle of permission sets for a persona Assigning everything a role needs at once
Muting permission set Up to one per group; turns off chosen permissions inside that group Removing a permission without changing shared permission sets
Session-based permission set Works only during an activated session Step-up access to sensitive actions
User access policy Rules that assign or remove permission sets, groups and licences Onboarding, job changes and migrating from profiles
  • Salesforce recommends the Minimum Access profile, or a clone of it, plus permission sets and groups.
  • Permission sets can only grant access, never deny it.
  • Muting only affects that group: if the user gets the permission from another source, they keep it.
  • Permission set assignments can have an expiration date for temporary access.
  • Standard profiles can't be edited: clone them.

Exam tip: "Doctors must see every patient regardless of sharing": View All on Patient for doctors only. "Remove one permission from a persona without touching shared permission sets": a muting permission set.

Field-level security

Field-level security or page layouts. Field-level security applies everywhere: record pages, related lists, list views, reports, search and the API, so it is real security. A page layout affects only detail and edit pages, and the field is still in reports and the API, so it is not security. View All Fields opens every current and future field of an object. Field-level security applies everywhere: pages, related lists, list views, reports, search and the API real security Page layout detail and edit pages only field still in reports and the API not security View All Fields opens every current and future field of an object
Field-level security or page layouts

Field-level security (FLS) controls whether a user can see or edit a field. It applies everywhere: record pages, related lists, list views, reports, search results and the API.

  • Set it in permission sets and permission set groups, or through a field's Field Accessibility view.
  • A field can be hidden, read-only or editable for a user.
  • When you create a field, you can set its field-level security for many permission sets at once.
  • The View All Fields object permission grants visibility of every current and future field on an object. Assign it through permission sets, not profiles.
  • An object can be visible while a sensitive field on it is hidden, such as an SSN field hidden from receptionists.
  • Some fields, such as the record ID, are always visible and can't be changed.
Need Use
Hide a field from a group of users completely Remove Read in field-level security
Let users see but not change a field Read-only field-level security
Give auditors every field, including future ones View All Fields on the object
Show a field only on some record pages A page layout or visibility rule, plus FLS if it must be secure

Exam tip: If a field must be hidden from a user anywhere, including reports and the API, the answer is field-level security, not the page layout.

Hiding data in the user interface

Scenario: Nurses complain that the patient page is cluttered with billing fields they never use. Billing staff must still see those fields.

What hides and what secures. Only hides: page layouts, Dynamic Forms rules, record types, removed buttons and search layouts. Actually secures: object permissions, field-level security, sharing settings, restriction rules and encryption at rest. Use UI controls for usability and security controls for protection. Only hides page layouts Dynamic Forms rules record types removed buttons search layouts Actually secures object permissions field-level security sharing settings restriction rules encryption at rest Use UI controls for usability; use security controls for protection
What hides and what secures

Mechanism What it does Security?
Page layouts Choose which fields and buttons appear on detail and edit pages No: fields still appear in reports, list views, search and the API
Dynamic Forms visibility rules Show or hide fields and sections by field value, device, profile or permission No: hidden fields are still in reports and dashboards
Component visibility rules Show a Lightning component only when conditions are met No
Record types Give different processes, layouts and picklist values No
Lightning page assignment Different record pages by app, record type and profile No
Removing a button, such as Sharing Hides the button No: the permission behind it remains
Search layouts and list views Choose which columns appear No: sharing and FLS still filter what users see
  • UI controls improve usability and reduce mistakes. Combine them with field-level security when the data must actually be protected.
  • In custom components, checks such as @salesforce/userPermission change the UI only; the server must still enforce access.

Exam tip: "Reduce clutter" points to page layouts, Dynamic Forms or record types. "Prevent access" always needs field-level security, object permissions or sharing.

Protecting sensitive data

Scenario: Patient diagnoses are health data, card numbers are payment data, and auditors want proof of who saw what. Developers test in a Full sandbox copied from production.

Controls for sensitive data. Who may see: field-level security, object permissions and sharing. Data at rest: Shield Platform Encryption and Database Encryption. Right now: Transaction Security blocks, requires MFA or notifies. After the fact: Event Monitoring and Field Audit Trail. Find it: Data Detect scans text fields for sensitive data. Sandboxes: Data Mask replaces real values for good. Who may see field-level security, object permissions, sharing Data at rest Shield Platform Encryption, Database Encryption Right now Transaction Security: block, require MFA, notify After the fact Event Monitoring and Field Audit Trail Find it Data Detect scans text fields for sensitive data Sandboxes Data Mask replaces real values for good
Controls for sensitive data

Control Protects against
Field-level security Unauthorized users seeing or editing a field anywhere
Shield Platform Encryption Exposure of data at rest: fields, files, search indexes and event data, with AES-256 keys
Database Encryption Encrypts the whole transactional database; once on, it can't be turned off
Classic Encryption Masks a special encrypted custom text field for users without View Encrypted Data
Restriction rules Users seeing records they'd otherwise reach through sharing
Transaction Security policies Risky actions in real time, such as large report exports: block, require MFA or notify
Event Monitoring Who did what, after the fact: logins, exports, API calls, page views
Field Audit Trail Changes to field values, kept long term
Data Detect Unknown sensitive data hiding in text fields
Data Mask Real sensitive data in sandboxes: masked permanently
Health Check Weak security settings, scored against a baseline
Session-based permission sets Sensitive actions without a step-up session

Encryption facts

  • Probabilistic encryption is the default and strongest; deterministic encryption allows more filtering, with slightly weaker protection.
  • Keys can be generated by Salesforce, brought by the customer, or managed externally.
  • Encryption protects stored data from attackers. Users who have field access still see plain values, so it doesn't replace field-level security.
  • Enabling Shield Platform Encryption needs Customize Application and Manage Encryption Keys.

Locking down highly confidential records

For a custom object that even executives mustn't see: set a Private default, turn off Grant Access Using Hierarchies, review who has View All or Modify All, and share only through explicit rules.

Exam tip: "Stop a user exporting a huge report right now": Transaction Security. "Show auditors who exported data last month": Event Monitoring. "Hide real card numbers from developers in a sandbox": Data Mask.

Enforcing security in code

Scenario: The clinic builds a custom Lightning component that shows patient details through an Apex controller. It must respect the same object, field and record access as the standard pages.

Enforcing security in Apex. with sharing enforces record access only, with no field checks. User mode enforces sharing, object and field permissions. stripInaccessible removes fields the user cannot see. System mode ignores object and field permissions. Lightning Data Service enforces everything automatically. From API 67.0, user mode and with sharing are the defaults. with sharing record access only, no field checks User mode sharing, object and field permissions stripInaccessible removes fields the user cannot see System mode ignores object and field permissions Lightning Data Service enforces everything automatically From API 67.0: user mode and with sharing are the defaults
Enforcing security in Apex

Sharing keywords and modes

Option Enforces
with sharing The running user's record access only
without sharing Nothing at record level: use for narrow, deliberate elevation
inherited sharing The caller's mode; with sharing when it's the entry point
User mode (WITH USER_MODE, insert as user) Sharing, object and field permissions, and restriction rules; reports every inaccessible field
System mode (WITH SYSTEM_MODE, as system) Ignores object and field permissions
Security.stripInaccessible() Removes fields the user can't access from records, instead of failing
WITH SECURITY_ENFORCED Object and field checks on queries, stopping at the first error; replaced by user mode

Defaults have changed

Code saved at API 66.0 or earlier API 67.0 and later
Object and field permissions System mode: ignored unless enforced User mode: enforced unless system mode is chosen
Class with no sharing keyword Usually without sharing with sharing
WITH SECURITY_ENFORCED Allowed Not allowed: use WITH USER_MODE

Triggers always run without sharing, but from API 67.0 their queries and DML default to user mode.

Components, pages and flows

  • Lightning Data Service, the UI API and base components such as lightning-record-form enforce object permissions, field-level security and sharing automatically.
  • Apex called from Lightning components isn't protected automatically: treat each @AuraEnabled method like a web service and enforce access on the server.
  • Users can call an Apex class only if their profile or a permission set grants access to it.
  • Visualforce standard controllers enforce sharing and object permissions; custom controllers need explicit checks.
  • All @RemoteAction methods on a controller can be called by anyone who can view the page.
  • Flows: user mode enforces permissions; system mode with sharing enforces sharing only; system mode without sharing reaches all data. Flows launched from the UI, such as screen flows, run in user mode by default; record-triggered flows run in system mode.

Exam tip: "Enforce sharing, object and field permissions in a query": WITH USER_MODE. "Return what the user may see without failing": Security.stripInaccessible. with sharing alone never checks field-level security.

Hands-on exercise

Secure a healthcare app

Give clinic staff the right object and field access, and protect patient data everywhere.

Use a free Salesforce Developer Edition org — never a production org.

0 of 6 steps done

How to check your work: Users share a Minimum Access profile with permission set groups per role; only billing sees card numbers through field-level security; no role relies on page layouts for security; Shield Platform Encryption, Data Mask and Transaction Security protect the data; and Apex uses user mode or stripInaccessible.

Domain quiz: Permissions to Standard Objects, Custom Objects, and Fields

10 questions from the 50 in this domain, different each time and checked as you go. Anything you miss is saved to Mistakes review.

Questions
10
Time
Untimed
Feedback
After each answer

New questions each time you start, drawn from the bank, unseen ones first.

Access to Records