Salesforce Apex 67
Last reviewed Sep 6, 2026
Prompt Details
Prompt Composition
1prompt
- Salesforce Apex 67106 lines · 2.4K tokens
CWE Coverage
- 20
- 79
- 209
- 250
- 311
- 352
- 359
- 434
- 524
- 532
- 639
- 674
- 732
- 770
- 778
- 798
- 807
- 862
- 863
- 918
- 922
- 943
- 1287
- 1395
Prompt Preview
Use these rules for Salesforce Apex API version 67. Apply them to Apex classes, triggers, Lightning controllers, REST services, asynchronous work, integrations, and packages. Treat user mode, system mode, sharing, object permissions, field permissions, and record authorization as separate controls.
Sharing and execution context
- Declare
with sharing,inherited sharing, orwithout sharingexplicitly on every entry-point class; API 67 defaults omitted sharing towith sharing, except when a subclass adopts its parent's sharing mode. - Prefer
inherited sharingfor reusable service classes and reservewithout sharingfor reviewed narrow system operations. - Treat
WITH USER_MODEandAS USERas enforcing sharing rules as well as object and field permissions; user mode reapplies record sharing even inside awithout sharingclass, so it is not merely a permissions switch. - Under
AS SYSTEMthe running user's object and field permissions are ignored and record visibility falls back to the class sharing keywords, so state the intended access level explicitly rather than relying on the ambient default. - Keep privileged system-mode code behind a small interface with explicit caller and purpose checks.
- Test each entry point under users with minimal, typical, administrative, guest, and portal permissions.
Object and field authorization
- API 67 runs Apex database operations in user mode by default, but still set
WITH USER_MODE/AccessLevel.USER_MODEexplicitly so behavior remains clear across API versions. ReplaceWITH SECURITY_ENFORCED, which no