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.
Four layers of access
- Org: who can log in, from where and when: login hours, trusted IP ranges and password policies.
- Objects: what users can do with an object's records: create, read, edit, delete.
- Fields: which fields they can see and edit.
- 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 (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.
| 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/userPermissionchange 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.
| 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.
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-formenforce object permissions, field-level security and sharing automatically. - Apex called from Lightning components isn't protected automatically: treat each
@AuraEnabledmethod 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
@RemoteActionmethods 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 sharingalone 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.