scc-universal 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +44 -0
- package/.cursor/agents/deep-researcher.md +142 -0
- package/.cursor/agents/doc-updater.md +219 -0
- package/.cursor/agents/eval-runner.md +335 -0
- package/.cursor/agents/learning-engine.md +210 -0
- package/.cursor/agents/loop-operator.md +245 -0
- package/.cursor/agents/refactor-cleaner.md +119 -0
- package/.cursor/agents/sf-admin-agent.md +127 -0
- package/.cursor/agents/sf-agentforce-agent.md +126 -0
- package/.cursor/agents/sf-apex-agent.md +117 -0
- package/.cursor/agents/sf-architect.md +426 -0
- package/.cursor/agents/sf-aura-reviewer.md +369 -0
- package/.cursor/agents/sf-bugfix-agent.md +101 -0
- package/.cursor/agents/sf-flow-agent.md +155 -0
- package/.cursor/agents/sf-integration-agent.md +141 -0
- package/.cursor/agents/sf-lwc-agent.md +123 -0
- package/.cursor/agents/sf-review-agent.md +357 -0
- package/.cursor/agents/sf-visualforce-reviewer.md +465 -0
- package/.cursor/hooks/adapter.js +81 -0
- package/.cursor/hooks/after-file-edit.js +26 -0
- package/.cursor/hooks/after-mcp-execution.js +12 -0
- package/.cursor/hooks/after-shell-execution.js +30 -0
- package/.cursor/hooks/after-tab-file-edit.js +12 -0
- package/.cursor/hooks/before-mcp-execution.js +11 -0
- package/.cursor/hooks/before-read-file.js +13 -0
- package/.cursor/hooks/before-shell-execution.js +29 -0
- package/.cursor/hooks/before-submit-prompt.js +23 -0
- package/.cursor/hooks/pre-compact.js +7 -0
- package/.cursor/hooks/session-end.js +10 -0
- package/.cursor/hooks/session-start.js +10 -0
- package/.cursor/hooks/stop.js +18 -0
- package/.cursor/hooks/subagent-start.js +10 -0
- package/.cursor/hooks/subagent-stop.js +10 -0
- package/.cursor/hooks.json +107 -0
- package/.cursor/skills/aside/SKILL.md +115 -0
- package/.cursor/skills/checkpoint/SKILL.md +50 -0
- package/.cursor/skills/configure-scc/SKILL.md +160 -0
- package/.cursor/skills/continuous-agent-loop/SKILL.md +260 -0
- package/.cursor/skills/mcp-server-patterns/SKILL.md +142 -0
- package/.cursor/skills/model-route/SKILL.md +81 -0
- package/.cursor/skills/prompt-optimizer/SKILL.md +366 -0
- package/.cursor/skills/refactor-clean/SKILL.md +133 -0
- package/.cursor/skills/resume-session/SKILL.md +111 -0
- package/.cursor/skills/save-session/SKILL.md +183 -0
- package/.cursor/skills/search-first/SKILL.md +140 -0
- package/.cursor/skills/security-scan/SKILL.md +142 -0
- package/.cursor/skills/sessions/SKILL.md +124 -0
- package/.cursor/skills/sf-agentforce-development/SKILL.md +449 -0
- package/.cursor/skills/sf-apex-async-patterns/SKILL.md +324 -0
- package/.cursor/skills/sf-apex-best-practices/SKILL.md +421 -0
- package/.cursor/skills/sf-apex-constraints/SKILL.md +79 -0
- package/.cursor/skills/sf-apex-cursor/SKILL.md +336 -0
- package/.cursor/skills/sf-apex-enterprise-patterns/SKILL.md +344 -0
- package/.cursor/skills/sf-apex-testing/SKILL.md +407 -0
- package/.cursor/skills/sf-api-design/SKILL.md +237 -0
- package/.cursor/skills/sf-approval-processes/SKILL.md +312 -0
- package/.cursor/skills/sf-aura-development/SKILL.md +260 -0
- package/.cursor/skills/sf-build-fix/SKILL.md +120 -0
- package/.cursor/skills/sf-data-modeling/SKILL.md +274 -0
- package/.cursor/skills/sf-debugging/SKILL.md +362 -0
- package/.cursor/skills/sf-deployment/SKILL.md +291 -0
- package/.cursor/skills/sf-deployment-constraints/SKILL.md +153 -0
- package/.cursor/skills/sf-devops-ci-cd/SKILL.md +322 -0
- package/.cursor/skills/sf-docs-lookup/SKILL.md +100 -0
- package/.cursor/skills/sf-e2e-testing/SKILL.md +321 -0
- package/.cursor/skills/sf-experience-cloud/SKILL.md +248 -0
- package/.cursor/skills/sf-flow-development/SKILL.md +376 -0
- package/.cursor/skills/sf-governor-limits/SKILL.md +319 -0
- package/.cursor/skills/sf-harness-audit/SKILL.md +139 -0
- package/.cursor/skills/sf-help/SKILL.md +156 -0
- package/.cursor/skills/sf-integration/SKILL.md +479 -0
- package/.cursor/skills/sf-lwc-constraints/SKILL.md +128 -0
- package/.cursor/skills/sf-lwc-development/SKILL.md +302 -0
- package/.cursor/skills/sf-lwc-testing/SKILL.md +387 -0
- package/.cursor/skills/sf-metadata-management/SKILL.md +285 -0
- package/.cursor/skills/sf-platform-events-cdc/SKILL.md +372 -0
- package/.cursor/skills/sf-quickstart/SKILL.md +170 -0
- package/.cursor/skills/sf-security/SKILL.md +330 -0
- package/.cursor/skills/sf-security-constraints/SKILL.md +125 -0
- package/.cursor/skills/sf-soql-constraints/SKILL.md +129 -0
- package/.cursor/skills/sf-soql-optimization/SKILL.md +353 -0
- package/.cursor/skills/sf-tdd-workflow/SKILL.md +332 -0
- package/.cursor/skills/sf-testing-constraints/SKILL.md +198 -0
- package/.cursor/skills/sf-trigger-constraints/SKILL.md +88 -0
- package/.cursor/skills/sf-trigger-frameworks/SKILL.md +343 -0
- package/.cursor/skills/sf-visualforce-development/SKILL.md +259 -0
- package/.cursor/skills/strategic-compact/SKILL.md +205 -0
- package/.cursor/skills/update-docs/SKILL.md +162 -0
- package/.cursor/skills/update-platform-docs/SKILL.md +86 -0
- package/.cursor-plugin/plugin.json +26 -0
- package/LICENSE +21 -0
- package/README.md +522 -0
- package/agents/deep-researcher.md +145 -0
- package/agents/doc-updater.md +222 -0
- package/agents/eval-runner.md +340 -0
- package/agents/learning-engine.md +211 -0
- package/agents/loop-operator.md +247 -0
- package/agents/refactor-cleaner.md +122 -0
- package/agents/sf-admin-agent.md +131 -0
- package/agents/sf-agentforce-agent.md +132 -0
- package/agents/sf-apex-agent.md +124 -0
- package/agents/sf-architect.md +435 -0
- package/agents/sf-aura-reviewer.md +372 -0
- package/agents/sf-bugfix-agent.md +105 -0
- package/agents/sf-flow-agent.md +159 -0
- package/agents/sf-integration-agent.md +146 -0
- package/agents/sf-lwc-agent.md +127 -0
- package/agents/sf-review-agent.md +366 -0
- package/agents/sf-visualforce-reviewer.md +468 -0
- package/assets/logo.svg +18 -0
- package/docs/ARCHITECTURE.md +133 -0
- package/docs/authoring-guide.md +373 -0
- package/docs/hook-development.md +578 -0
- package/docs/token-optimization.md +139 -0
- package/docs/workflow-examples.md +645 -0
- package/examples/agentforce-action/README.md +227 -0
- package/examples/apex-trigger-handler/README.md +114 -0
- package/examples/devops-pipeline/README.md +325 -0
- package/examples/flow-automation/README.md +188 -0
- package/examples/integration-pattern/README.md +416 -0
- package/examples/lwc-component/README.md +180 -0
- package/examples/platform-events/README.md +492 -0
- package/examples/scratch-org-setup/README.md +138 -0
- package/examples/security-audit/README.md +244 -0
- package/examples/visualforce-migration/README.md +314 -0
- package/hooks/hooks.json +338 -0
- package/hooks/memory-persistence/README.md +73 -0
- package/manifests/install-modules.json +217 -0
- package/manifests/install-profiles.json +17 -0
- package/mcp-configs/mcp-servers.json +19 -0
- package/package.json +89 -0
- package/schemas/hooks.schema.json +123 -0
- package/schemas/install-modules.schema.json +76 -0
- package/schemas/install-profiles.schema.json +28 -0
- package/schemas/install-state.schema.json +73 -0
- package/schemas/package-manager.schema.json +18 -0
- package/schemas/plugin.schema.json +112 -0
- package/schemas/scc-install-config.schema.json +29 -0
- package/schemas/state-store.schema.json +111 -0
- package/scripts/cli/install-apply.js +170 -0
- package/scripts/cli/uninstall.js +193 -0
- package/scripts/hooks/check-console-log.js +101 -0
- package/scripts/hooks/check-hook-enabled.js +17 -0
- package/scripts/hooks/check-platform-docs-age.js +48 -0
- package/scripts/hooks/cost-tracker.js +78 -0
- package/scripts/hooks/doc-file-warning.js +63 -0
- package/scripts/hooks/evaluate-session.js +98 -0
- package/scripts/hooks/governor-check.js +220 -0
- package/scripts/hooks/learning-observe.sh +206 -0
- package/scripts/hooks/mcp-health-check.js +588 -0
- package/scripts/hooks/post-bash-build-complete.js +34 -0
- package/scripts/hooks/post-bash-pr-created.js +43 -0
- package/scripts/hooks/post-edit-console-warn.js +61 -0
- package/scripts/hooks/post-edit-format.js +79 -0
- package/scripts/hooks/post-edit-typecheck.js +98 -0
- package/scripts/hooks/post-write.js +168 -0
- package/scripts/hooks/pre-bash-git-push-reminder.js +35 -0
- package/scripts/hooks/pre-bash-tmux-reminder.js +47 -0
- package/scripts/hooks/pre-compact.js +51 -0
- package/scripts/hooks/pre-tool-use.js +163 -0
- package/scripts/hooks/pre-write-doc-warn.js +9 -0
- package/scripts/hooks/quality-gate.js +251 -0
- package/scripts/hooks/run-with-flags-shell.sh +32 -0
- package/scripts/hooks/run-with-flags.js +135 -0
- package/scripts/hooks/session-end-marker.js +29 -0
- package/scripts/hooks/session-end.js +311 -0
- package/scripts/hooks/session-start.js +202 -0
- package/scripts/hooks/sfdx-scanner-check.js +142 -0
- package/scripts/hooks/sfdx-validate.js +119 -0
- package/scripts/hooks/stop-hook.js +170 -0
- package/scripts/hooks/suggest-compact.js +67 -0
- package/scripts/lib/agent-adapter.js +82 -0
- package/scripts/lib/apex-analysis.js +194 -0
- package/scripts/lib/hook-flags.js +74 -0
- package/scripts/lib/install-config.js +73 -0
- package/scripts/lib/install-executor.js +363 -0
- package/scripts/lib/install-state.js +121 -0
- package/scripts/lib/orchestration-session.js +299 -0
- package/scripts/lib/package-manager.js +124 -0
- package/scripts/lib/project-detect.js +228 -0
- package/scripts/lib/schema-validator.js +190 -0
- package/scripts/lib/skill-adapter.js +100 -0
- package/scripts/lib/state-store.js +376 -0
- package/scripts/lib/tmux-worktree-orchestrator.js +598 -0
- package/scripts/lib/utils.js +313 -0
- package/scripts/scc.js +164 -0
- package/skills/_reference/AGENTFORCE_PATTERNS.md +112 -0
- package/skills/_reference/APEX_CURSOR.md +159 -0
- package/skills/_reference/API_VERSIONS.md +78 -0
- package/skills/_reference/APPROVAL_PROCESSES.md +105 -0
- package/skills/_reference/ASYNC_PATTERNS.md +163 -0
- package/skills/_reference/AURA_COMPONENTS.md +146 -0
- package/skills/_reference/DATA_MIGRATION_PATTERNS.md +151 -0
- package/skills/_reference/DATA_MODELING.md +124 -0
- package/skills/_reference/DEBUGGING_TOOLS.md +140 -0
- package/skills/_reference/DEPLOYMENT_CHECKLIST.md +87 -0
- package/skills/_reference/DEPRECATIONS.md +79 -0
- package/skills/_reference/DOCKER_CI_PATTERNS.md +138 -0
- package/skills/_reference/ENTERPRISE_PATTERNS.md +122 -0
- package/skills/_reference/EXPERIENCE_CLOUD.md +143 -0
- package/skills/_reference/FLOW_PATTERNS.md +113 -0
- package/skills/_reference/GOVERNOR_LIMITS.md +77 -0
- package/skills/_reference/INTEGRATION_PATTERNS.md +105 -0
- package/skills/_reference/LWC_PATTERNS.md +79 -0
- package/skills/_reference/METADATA_TYPES.md +115 -0
- package/skills/_reference/NAMING_CONVENTIONS.md +84 -0
- package/skills/_reference/PACKAGE_DEVELOPMENT.md +150 -0
- package/skills/_reference/PLATFORM_EVENTS.md +121 -0
- package/skills/_reference/REPORTING_API.md +143 -0
- package/skills/_reference/SCRATCH_ORG_PATTERNS.md +126 -0
- package/skills/_reference/SECURITY_PATTERNS.md +127 -0
- package/skills/_reference/SHARING_MODEL.md +120 -0
- package/skills/_reference/SOQL_PATTERNS.md +119 -0
- package/skills/_reference/TESTING_STANDARDS.md +96 -0
- package/skills/_reference/TRIGGER_PATTERNS.md +114 -0
- package/skills/_reference/VISUALFORCE_PATTERNS.md +121 -0
- package/skills/aside/SKILL.md +118 -0
- package/skills/checkpoint/SKILL.md +53 -0
- package/skills/configure-scc/SKILL.md +163 -0
- package/skills/continuous-agent-loop/SKILL.md +264 -0
- package/skills/mcp-server-patterns/SKILL.md +146 -0
- package/skills/model-route/SKILL.md +84 -0
- package/skills/prompt-optimizer/SKILL.md +369 -0
- package/skills/refactor-clean/SKILL.md +136 -0
- package/skills/resume-session/SKILL.md +114 -0
- package/skills/save-session/SKILL.md +186 -0
- package/skills/search-first/SKILL.md +144 -0
- package/skills/security-scan/SKILL.md +146 -0
- package/skills/sessions/SKILL.md +127 -0
- package/skills/sf-agentforce-development/SKILL.md +450 -0
- package/skills/sf-apex-async-patterns/SKILL.md +326 -0
- package/skills/sf-apex-best-practices/SKILL.md +425 -0
- package/skills/sf-apex-constraints/SKILL.md +81 -0
- package/skills/sf-apex-cursor/SKILL.md +338 -0
- package/skills/sf-apex-enterprise-patterns/SKILL.md +348 -0
- package/skills/sf-apex-testing/SKILL.md +409 -0
- package/skills/sf-api-design/SKILL.md +238 -0
- package/skills/sf-approval-processes/SKILL.md +315 -0
- package/skills/sf-aura-development/SKILL.md +263 -0
- package/skills/sf-build-fix/SKILL.md +121 -0
- package/skills/sf-data-modeling/SKILL.md +278 -0
- package/skills/sf-debugging/SKILL.md +363 -0
- package/skills/sf-deployment/SKILL.md +295 -0
- package/skills/sf-deployment-constraints/SKILL.md +155 -0
- package/skills/sf-devops-ci-cd/SKILL.md +325 -0
- package/skills/sf-docs-lookup/SKILL.md +103 -0
- package/skills/sf-e2e-testing/SKILL.md +324 -0
- package/skills/sf-experience-cloud/SKILL.md +249 -0
- package/skills/sf-flow-development/SKILL.md +377 -0
- package/skills/sf-governor-limits/SKILL.md +323 -0
- package/skills/sf-harness-audit/SKILL.md +142 -0
- package/skills/sf-help/SKILL.md +159 -0
- package/skills/sf-integration/SKILL.md +483 -0
- package/skills/sf-lwc-constraints/SKILL.md +130 -0
- package/skills/sf-lwc-development/SKILL.md +303 -0
- package/skills/sf-lwc-testing/SKILL.md +388 -0
- package/skills/sf-metadata-management/SKILL.md +288 -0
- package/skills/sf-platform-events-cdc/SKILL.md +375 -0
- package/skills/sf-quickstart/SKILL.md +173 -0
- package/skills/sf-security/SKILL.md +334 -0
- package/skills/sf-security-constraints/SKILL.md +127 -0
- package/skills/sf-soql-constraints/SKILL.md +131 -0
- package/skills/sf-soql-optimization/SKILL.md +354 -0
- package/skills/sf-tdd-workflow/SKILL.md +336 -0
- package/skills/sf-testing-constraints/SKILL.md +200 -0
- package/skills/sf-trigger-constraints/SKILL.md +90 -0
- package/skills/sf-trigger-frameworks/SKILL.md +347 -0
- package/skills/sf-visualforce-development/SKILL.md +260 -0
- package/skills/strategic-compact/SKILL.md +208 -0
- package/skills/update-docs/SKILL.md +165 -0
- package/skills/update-platform-docs/SKILL.md +90 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<!-- Source: https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/sforce_analytics_rest_api_intro.htm -->
|
|
2
|
+
<!-- Last verified: API v66.0 — 2026-03-29 -->
|
|
3
|
+
|
|
4
|
+
# Reporting & Analytics API — Salesforce Reference
|
|
5
|
+
|
|
6
|
+
## Report Formats
|
|
7
|
+
|
|
8
|
+
| Format | Grouping | Summary Fields | Use Case |
|
|
9
|
+
|---|---|---|---|
|
|
10
|
+
| Tabular | None | Column totals only | Flat lists, CSV export |
|
|
11
|
+
| Summary | Up to 3 row groupings | Subtotals per group | Grouped data with subtotals |
|
|
12
|
+
| Matrix | Row AND column groupings | Intersection summaries | Cross-tabulation / pivot |
|
|
13
|
+
| Joined | Per-block groupings (up to 5 blocks) | Per-block summaries | Side-by-side comparisons |
|
|
14
|
+
|
|
15
|
+
## Analytics REST API Endpoints
|
|
16
|
+
|
|
17
|
+
Base path: `/services/data/v{version}/analytics`
|
|
18
|
+
|
|
19
|
+
### Report Endpoints
|
|
20
|
+
|
|
21
|
+
| Method | URI | Description |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| GET | `/reports` | List up to 200 recently viewed reports |
|
|
24
|
+
| POST | `/reports` | Create a new report |
|
|
25
|
+
| GET | `/reports/{id}` | Retrieve report metadata |
|
|
26
|
+
| PUT | `/reports/{id}` | Save report changes |
|
|
27
|
+
| DELETE | `/reports/{id}` | Delete a report |
|
|
28
|
+
| GET | `/reports/{id}/describe` | Get report structure (fields, groupings, filters) |
|
|
29
|
+
| GET | `/reports/{id}/instances` | List async report run instances |
|
|
30
|
+
| POST | `/reports/{id}/instances` | Execute report asynchronously |
|
|
31
|
+
| GET | `/reports/{id}/instances/{instanceId}` | Retrieve async execution results |
|
|
32
|
+
|
|
33
|
+
### Dashboard Endpoints
|
|
34
|
+
|
|
35
|
+
| Method | URI | Description |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| GET | `/dashboards` | List recently viewed dashboards |
|
|
38
|
+
| GET | `/dashboards/{id}` | Retrieve dashboard metadata and status |
|
|
39
|
+
| PUT | `/dashboards/{id}` | Update dashboard |
|
|
40
|
+
| DELETE | `/dashboards/{id}` | Delete dashboard |
|
|
41
|
+
| GET | `/dashboards/{id}/describe` | Dashboard structure info |
|
|
42
|
+
| POST | `/dashboards/{id}/instances` | Execute async dashboard refresh |
|
|
43
|
+
|
|
44
|
+
### Report Type Endpoints (API v39.0+)
|
|
45
|
+
|
|
46
|
+
| Method | URI | Description |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| GET | `/reportTypes` | List available report types |
|
|
49
|
+
| GET | `/reportTypes/{type}` | Get single report type detail |
|
|
50
|
+
|
|
51
|
+
## API Limits
|
|
52
|
+
|
|
53
|
+
| Limit | Value |
|
|
54
|
+
|---|---|
|
|
55
|
+
| Synchronous report runs per hour (org) | 500 |
|
|
56
|
+
| Concurrent synchronous report requests | 20 |
|
|
57
|
+
| Detail rows returned per run | 2,000 (sync); larger via async |
|
|
58
|
+
| Async report instances listed | Up to 2,000 |
|
|
59
|
+
| Async results retention | 24-hour rolling window |
|
|
60
|
+
| Dashboard refreshes per hour (org) | 200 |
|
|
61
|
+
| Custom field filters at runtime | Up to 20 |
|
|
62
|
+
| Dashboard filters per dashboard | Up to 5 |
|
|
63
|
+
|
|
64
|
+
## Apex Analytics API Classes
|
|
65
|
+
|
|
66
|
+
| Class | Purpose |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `Reports.ReportManager` | Run, describe, list reports |
|
|
69
|
+
| `Reports.ReportResults` | Access fact map, metadata, totals |
|
|
70
|
+
| `Reports.ReportMetadata` | Read/modify filters, groupings, columns |
|
|
71
|
+
| `Reports.ReportExtendedMetadata` | Aggregate column info, detail columns |
|
|
72
|
+
| `Reports.ReportFilter` | Set column, operator, value for runtime filter |
|
|
73
|
+
| `Reports.ReportInstance` | Handle async report execution + status |
|
|
74
|
+
| `Reports.ReportFactWithDetails` | Traverse row data + aggregates |
|
|
75
|
+
| `Reports.SummaryValue` | Individual aggregate value (label + value) |
|
|
76
|
+
| `Reports.ReportDetailRow` | Single row of detail data |
|
|
77
|
+
| `Reports.ReportDataCell` | Single cell (label + value) |
|
|
78
|
+
|
|
79
|
+
## Fact Map Keys
|
|
80
|
+
|
|
81
|
+
| Key | Meaning |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `T!T` | Grand total row and column |
|
|
84
|
+
| `0!T` | First row grouping, all columns |
|
|
85
|
+
| `T!0` | All rows, first column grouping |
|
|
86
|
+
| `0!0` | First row grouping, first column grouping |
|
|
87
|
+
| `{row}_{col}` | Specific intersection in matrix report |
|
|
88
|
+
|
|
89
|
+
## Custom Report Type Relationship Patterns
|
|
90
|
+
|
|
91
|
+
| Pattern | Description | SQL Equivalent |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| A with B | A must have related B records | INNER JOIN |
|
|
94
|
+
| A with or without B | A included even without B | LEFT OUTER JOIN |
|
|
95
|
+
| A with B, B with C | Three-level relationship | Double JOIN |
|
|
96
|
+
|
|
97
|
+
Max objects in a custom report type: 4 (A-B-C-D chain).
|
|
98
|
+
|
|
99
|
+
## Dashboard Component Types
|
|
100
|
+
|
|
101
|
+
| Component | Best For | Data Source |
|
|
102
|
+
|---|---|---|
|
|
103
|
+
| Chart (bar, line, pie, donut, funnel) | Visual trends, comparisons | Source report |
|
|
104
|
+
| Gauge | Progress toward a target value | Source report + target |
|
|
105
|
+
| Metric | Single KPI number | Source report |
|
|
106
|
+
| Table | Tabular data in dashboard | Source report |
|
|
107
|
+
| Lightning Component | Custom interactive widget | Custom LWC |
|
|
108
|
+
|
|
109
|
+
## Filter Types
|
|
110
|
+
|
|
111
|
+
| Filter Type | Scope | Example |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| Standard Filter | Predefined (Show Me, Date) | "My accounts", "This quarter" |
|
|
114
|
+
| Field Filter | Any field on report type | `Amount > 50000` |
|
|
115
|
+
| Cross Filter | Related object existence | "Accounts WITH Opportunities" |
|
|
116
|
+
| Row Limit | Cap result count | "Top 10 by Amount" |
|
|
117
|
+
| Bucket Field | Group values without formula | Amount ranges: Small/Medium/Large |
|
|
118
|
+
|
|
119
|
+
## Report Metadata Source Format
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
reports/<FolderName>/<ReportName>.report-meta.xml
|
|
123
|
+
dashboards/<FolderName>/<DashboardName>.dashboard-meta.xml
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## CLI Commands
|
|
127
|
+
|
|
128
|
+
| Command | Purpose |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `sf project retrieve start --metadata Report:<folder/name>` | Retrieve a report |
|
|
131
|
+
| `sf project deploy start --source-dir force-app/main/default/reports` | Deploy reports |
|
|
132
|
+
| `sf project retrieve start --metadata Dashboard:<folder/name>` | Retrieve a dashboard |
|
|
133
|
+
|
|
134
|
+
## Performance Anti-Patterns
|
|
135
|
+
|
|
136
|
+
| Anti-Pattern | Fix |
|
|
137
|
+
|---|---|
|
|
138
|
+
| Large object reports without date filters | Always add date range filter |
|
|
139
|
+
| More than 3 cross-filters | Use custom report types instead |
|
|
140
|
+
| Custom report type with 4+ objects | Limit to 2-3; use formula fields |
|
|
141
|
+
| Dashboard with 20+ components | Keep to 10-12 focused components |
|
|
142
|
+
| Hardcoded report IDs in Apex | Store DeveloperName in Custom Metadata |
|
|
143
|
+
| Synchronous `runReport()` for >2,000 rows | Use `runAsyncReport()` or Batch Apex |
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<!-- Source: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs.htm -->
|
|
2
|
+
<!-- Last verified: API v66.0 — 2026-03-29 -->
|
|
3
|
+
<!-- ⚠️ UNVERIFIED — Salesforce docs site returned JS-only content; facts sourced from Trailhead + skill knowledge -->
|
|
4
|
+
|
|
5
|
+
# Scratch Org Patterns — Salesforce Reference
|
|
6
|
+
|
|
7
|
+
## project-scratch-def.json Top-Level Fields
|
|
8
|
+
|
|
9
|
+
| Field | Type | Required | Notes |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| `orgName` | string | No | Display name |
|
|
12
|
+
| `edition` | string | Yes | See editions table below |
|
|
13
|
+
| `hasSampleData` | boolean | No | Default `false` |
|
|
14
|
+
| `language` | string | No | e.g. `en_US` |
|
|
15
|
+
| `country` | string | No | e.g. `US` |
|
|
16
|
+
| `adminEmail` | string | No | Admin user email |
|
|
17
|
+
| `description` | string | No | Free-text |
|
|
18
|
+
| `duration` | integer | No | 1–30 days; default 7 |
|
|
19
|
+
| `features` | string[] | No | See features table |
|
|
20
|
+
| `settings` | object | No | Nested settings objects |
|
|
21
|
+
| `sourceOrg` | string | No | Org ID for org shape |
|
|
22
|
+
| `snapshot` | string | No | Snapshot name (pilot) |
|
|
23
|
+
|
|
24
|
+
## Supported Editions
|
|
25
|
+
|
|
26
|
+
| Edition | Use Case |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `Developer` | Standard development; most features available |
|
|
29
|
+
| `Enterprise` | Testing enterprise-specific features |
|
|
30
|
+
| `Partner Developer` | ISV / partner development |
|
|
31
|
+
| `Group` | Testing simplified CRM features |
|
|
32
|
+
|
|
33
|
+
## Common Features
|
|
34
|
+
|
|
35
|
+
| Feature | Purpose |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `API` | API access (always include) |
|
|
38
|
+
| `AuthorApex` | Apex development |
|
|
39
|
+
| `Communities` | Experience Cloud |
|
|
40
|
+
| `ContactsToMultipleAccounts` | Multi-account contacts |
|
|
41
|
+
| `CustomProfiles` | Custom user profiles |
|
|
42
|
+
| `DebugApex` | Apex debugger |
|
|
43
|
+
| `EnableSetPasswordInApi` | Set passwords via API |
|
|
44
|
+
| `FieldService` | Field Service Lightning |
|
|
45
|
+
| `LightningExperienceEnabled` | Lightning UI (always include) |
|
|
46
|
+
| `LiveAgentEnabled` | Live Agent chat |
|
|
47
|
+
| `MultiCurrency` | Multi-currency support |
|
|
48
|
+
| `Omnichannel` | Omni-Channel routing |
|
|
49
|
+
| `PersonAccounts` | Person Account record type |
|
|
50
|
+
| `SalesUser` | Sales Cloud user features |
|
|
51
|
+
| `ServiceUser` | Service Cloud user features |
|
|
52
|
+
| `Sites` | Salesforce Sites |
|
|
53
|
+
| `Territory2` | Territory Management 2.0 |
|
|
54
|
+
| `Translation` | Translation Workbench |
|
|
55
|
+
|
|
56
|
+
## Dev Hub Scratch Org Limits
|
|
57
|
+
|
|
58
|
+
| Dev Hub Edition | Active Orgs | Daily Creates |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| Developer Edition | 6 | 3 |
|
|
61
|
+
| Enterprise (paid) | 40 | 20 |
|
|
62
|
+
| Unlimited (paid) | 100 | 40 |
|
|
63
|
+
|
|
64
|
+
## Duration Strategy
|
|
65
|
+
|
|
66
|
+
| Scenario | Duration | Definition File |
|
|
67
|
+
|---|---|---|
|
|
68
|
+
| CI pipeline | 1–3 days | Minimal (3 features: API, AuthorApex, DebugApex) |
|
|
69
|
+
| Feature development | 7 days (default) | Full project scratch def |
|
|
70
|
+
| Complex feature | Up to 30 days (max) | Full project scratch def |
|
|
71
|
+
|
|
72
|
+
Minimal CI orgs spin up in ~2–3 min vs 5+ min for feature-rich orgs.
|
|
73
|
+
|
|
74
|
+
## Core CLI Commands
|
|
75
|
+
|
|
76
|
+
| Command | Purpose |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `sf org create scratch --definition-file <path> --alias <name> --set-default --duration-days <n>` | Create scratch org |
|
|
79
|
+
| `sf project deploy start --source-dir force-app --target-org <alias>` | Push source to org |
|
|
80
|
+
| `sf project retrieve start --source-dir force-app --target-org <alias>` | Pull changes from org |
|
|
81
|
+
| `sf project deploy preview --source-dir force-app --target-org <alias>` | Preview local changes not yet pushed |
|
|
82
|
+
| `sf project retrieve preview --source-dir force-app --target-org <alias>` | Preview org changes not yet pulled |
|
|
83
|
+
| `sf project deploy start --ignore-conflicts --target-org <alias>` | Force push (resolve conflict: local wins) |
|
|
84
|
+
| `sf project retrieve start --ignore-conflicts --target-org <alias>` | Force pull (resolve conflict: org wins) |
|
|
85
|
+
| `sf project reset tracking --target-org <alias>` | Reset corrupted source tracking |
|
|
86
|
+
| `sf org list --verbose` | List all scratch orgs |
|
|
87
|
+
| `sf org display --target-org <alias>` | Show org details and expiry |
|
|
88
|
+
| `sf org delete scratch --target-org <alias> --no-prompt` | Delete and free allocation |
|
|
89
|
+
| `sf org open --target-org <alias>` | Open org in browser |
|
|
90
|
+
| `sf config set target-org <alias>` | Set default target org |
|
|
91
|
+
|
|
92
|
+
## Org Shape & Snapshots
|
|
93
|
+
|
|
94
|
+
| Feature | Status | Prerequisites |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| Org Shape | GA | "Org Shape" enabled in Dev Hub; source org = production or Developer Edition; user needs "Manage Org Shapes" permission |
|
|
97
|
+
| Scratch Org Snapshots | Pilot/Beta | Requires Salesforce enablement; contact account team |
|
|
98
|
+
|
|
99
|
+
## sfdx-project.json Key Fields
|
|
100
|
+
|
|
101
|
+
| Field | Purpose |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `packageDirectories[].path` | Source directory (e.g. `force-app`) |
|
|
104
|
+
| `packageDirectories[].default` | Primary package directory |
|
|
105
|
+
| `packageDirectories[].package` | Package name (for packaging) |
|
|
106
|
+
| `packageDirectories[].versionNumber` | e.g. `1.0.0.NEXT` |
|
|
107
|
+
| `packageDirectories[].dependencies` | Array of `{ package, versionNumber }` |
|
|
108
|
+
| `namespace` | Package namespace (empty string = no namespace) |
|
|
109
|
+
| `sourceApiVersion` | e.g. `66.0` |
|
|
110
|
+
| `packageAliases` | Map of alias to Salesforce ID |
|
|
111
|
+
|
|
112
|
+
> **Note:** `sfdcLoginUrl` is deprecated. Use `sf org login web --instance-url` instead.
|
|
113
|
+
|
|
114
|
+
## Daily Dev Workflow Summary
|
|
115
|
+
|
|
116
|
+
| Step | Command |
|
|
117
|
+
|---|---|
|
|
118
|
+
| 1. Auth Dev Hub (one-time) | `sf org login web --set-default-dev-hub --alias devhub` |
|
|
119
|
+
| 2. Create scratch org | `sf org create scratch --definition-file config/project-scratch-def.json --alias feature-123 --set-default --duration-days 7` |
|
|
120
|
+
| 3. Install dependencies | `sf package install --package 04t... --target-org feature-123 --wait 10` |
|
|
121
|
+
| 4. Push source | `sf project deploy start --source-dir force-app --target-org feature-123` |
|
|
122
|
+
| 5. Load test data | `sf apex run --file scripts/apex/create-test-data.apex --target-org feature-123` |
|
|
123
|
+
| 6. Open org | `sf org open --target-org feature-123` |
|
|
124
|
+
| 7. Pull declarative changes | `sf project retrieve start --source-dir force-app --target-org feature-123` |
|
|
125
|
+
| 8. Deploy with tests | `sf project deploy start --source-dir force-app --test-level RunLocalTests --target-org feature-123` |
|
|
126
|
+
| 9. Delete when done | `sf org delete scratch --target-org feature-123 --no-prompt` |
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Security Patterns — Salesforce Reference
|
|
2
|
+
|
|
3
|
+
> Last verified: API v66.0 (Spring '26)
|
|
4
|
+
> Source: <https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_security_guide.htm>
|
|
5
|
+
|
|
6
|
+
## Salesforce Security Layers
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
Authentication & Authorization → Who can log in? (SSO, MFA, Login Flows)
|
|
10
|
+
Object-Level Security (CRUD) → Can user create/read/edit/delete this object? (Profiles, Permission Sets)
|
|
11
|
+
Field-Level Security (FLS) → Can user see/edit this field? (Profiles, Permission Sets)
|
|
12
|
+
Record-Level Security (Sharing) → Can user see THIS specific record? (OWD, Sharing Rules, Role Hierarchy)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The UI enforces all layers automatically. Apex and SOQL require explicit enforcement.
|
|
16
|
+
|
|
17
|
+
## CRUD + FLS Enforcement
|
|
18
|
+
|
|
19
|
+
| Approach | Min API | Enforces | Behavior on Violation |
|
|
20
|
+
|---|---|---|---|
|
|
21
|
+
| `WITH USER_MODE` (SOQL) | v56.0 | CRUD + FLS | Throws `QueryException` |
|
|
22
|
+
| `AccessLevel.USER_MODE` (DML) | v56.0 | CRUD + FLS | Throws `DmlException` |
|
|
23
|
+
| `WITH SECURITY_ENFORCED` (SOQL) | v48.0 | CRUD + FLS (reads) | Throws `QueryException` |
|
|
24
|
+
| `Security.stripInaccessible()` | v48.0 | FLS only | Silently removes inaccessible fields |
|
|
25
|
+
| Manual `isAccessible()` / `isCreateable()` checks | All | CRUD only (per call) | Developer-controlled |
|
|
26
|
+
|
|
27
|
+
### Preferred: WITH USER_MODE / AccessLevel.USER_MODE
|
|
28
|
+
|
|
29
|
+
```apex
|
|
30
|
+
// SOQL — enforces CRUD + FLS for running user
|
|
31
|
+
List<Account> accounts = [SELECT Id, Name FROM Account WITH USER_MODE];
|
|
32
|
+
|
|
33
|
+
// DML — enforces CRUD + FLS for running user
|
|
34
|
+
Database.insert(records, false, AccessLevel.USER_MODE);
|
|
35
|
+
Database.update(records, false, AccessLevel.USER_MODE);
|
|
36
|
+
Database.delete(records, false, AccessLevel.USER_MODE);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### stripInaccessible Warning
|
|
40
|
+
|
|
41
|
+
`Security.stripInaccessible()` **silently removes** fields the user cannot access. Stripped fields become `null`. Always check `getRemovedFields()` before passing records downstream — otherwise `NullPointerException` can occur on fields assumed to be populated.
|
|
42
|
+
|
|
43
|
+
## Sharing Keywords
|
|
44
|
+
|
|
45
|
+
| Keyword | Behavior | Default For |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `with sharing` | Enforces record-level sharing rules | User-facing classes (recommended default) |
|
|
48
|
+
| `without sharing` | Bypasses sharing rules — sees all records | System batch jobs (must justify) |
|
|
49
|
+
| `inherited sharing` | Adopts caller's sharing context | Utility/helper classes |
|
|
50
|
+
| (none specified) | Defaults to `without sharing` for existing code | — (always specify explicitly) |
|
|
51
|
+
|
|
52
|
+
### Decision Tree
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
User-facing code (LWC, VF, Aura, REST API)? → with sharing
|
|
56
|
+
Utility class called by different contexts? → inherited sharing
|
|
57
|
+
Scheduled batch / system processing? → without sharing (with justification)
|
|
58
|
+
When in doubt? → with sharing
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Critical Rule
|
|
62
|
+
|
|
63
|
+
Sharing context does **NOT** propagate to called classes. A `with sharing` class calling a `without sharing` class — the called method runs **without sharing**. Each class enforces its own declared keyword independently.
|
|
64
|
+
|
|
65
|
+
## SOQL Injection Prevention
|
|
66
|
+
|
|
67
|
+
| Approach | Security Level | When to Use |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| Static SOQL with `:bindVariable` | Safest | When query structure is fixed |
|
|
70
|
+
| `Database.queryWithBinds()` | Safe | When query structure must be dynamic |
|
|
71
|
+
| `String.escapeSingleQuotes()` | Legacy — adequate | When bind variables are not possible |
|
|
72
|
+
| String concatenation | **VULNERABLE** | Never |
|
|
73
|
+
|
|
74
|
+
### Safe Dynamic SOQL Pattern
|
|
75
|
+
|
|
76
|
+
When dynamic fields/sort are needed, **whitelist-validate** every dynamic component against known-safe values. Only filter values should use bind variables.
|
|
77
|
+
|
|
78
|
+
## XSS Prevention
|
|
79
|
+
|
|
80
|
+
### Visualforce
|
|
81
|
+
|
|
82
|
+
| Context | Encoding Function |
|
|
83
|
+
|---|---|
|
|
84
|
+
| HTML body | `{!HTMLENCODE(value)}` |
|
|
85
|
+
| HTML attribute | `{!HTMLENCODE(value)}` |
|
|
86
|
+
| JavaScript string | `{!JSENCODE(value)}` |
|
|
87
|
+
| JS inside HTML attribute | `{!JSINHTMLENCODE(value)}` |
|
|
88
|
+
| URL parameter | `{!URLENCODE(value)}` |
|
|
89
|
+
| Auto-safe components | `<apex:outputField>`, `<apex:outputText escape="true">` |
|
|
90
|
+
|
|
91
|
+
### LWC
|
|
92
|
+
|
|
93
|
+
LWC templates auto-encode HTML by default. Avoid `element.innerHTML = userInput` — use `textContent` or `<lightning-formatted-rich-text>` instead.
|
|
94
|
+
|
|
95
|
+
## Named Credentials & External Credentials
|
|
96
|
+
|
|
97
|
+
| Rule | Detail |
|
|
98
|
+
|---|---|
|
|
99
|
+
| Use `callout:NamedCredential` prefix | Salesforce injects auth at runtime |
|
|
100
|
+
| Never hardcode API keys/tokens in Apex | Use External Credentials (API v54.0+) |
|
|
101
|
+
| Never hardcode Record IDs | Differ per org/sandbox |
|
|
102
|
+
| Never hardcode endpoint URLs | Use Named Credentials or Custom Metadata |
|
|
103
|
+
| Never log secrets via `System.debug` | Exposed in debug logs |
|
|
104
|
+
|
|
105
|
+
## Security Review Checklist
|
|
106
|
+
|
|
107
|
+
- [ ] All user-facing SOQL uses `WITH USER_MODE` or explicit CRUD/FLS checks
|
|
108
|
+
- [ ] No SOQL string concatenation with user input
|
|
109
|
+
- [ ] Service classes declared `with sharing` by default
|
|
110
|
+
- [ ] `without sharing` justified and documented
|
|
111
|
+
- [ ] No hardcoded IDs, credentials, or endpoint URLs
|
|
112
|
+
- [ ] No `System.debug` of sensitive field values
|
|
113
|
+
- [ ] DML for user-facing operations uses `AccessLevel.USER_MODE`
|
|
114
|
+
- [ ] Callouts use Named Credentials / External Credentials
|
|
115
|
+
- [ ] Configuration uses Custom Metadata or Custom Settings
|
|
116
|
+
|
|
117
|
+
## Common Security Review Failures
|
|
118
|
+
|
|
119
|
+
| Pattern | Risk | Fix |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| Missing CRUD check on DML | Unauthorized data access | `AccessLevel.USER_MODE` |
|
|
122
|
+
| Missing FLS check on field access | Sensitive data exposure | `WITH USER_MODE` or `stripInaccessible` |
|
|
123
|
+
| Dynamic SOQL with string concatenation | SOQL injection | Bind variables or `queryWithBinds` |
|
|
124
|
+
| `without sharing` on user-facing class | Record-level bypass | `with sharing` |
|
|
125
|
+
| Hardcoded credentials | Credential exposure | Named Credentials |
|
|
126
|
+
| Sensitive data in debug logs | Data leakage | Remove debug statements |
|
|
127
|
+
| `element.innerHTML = userInput` | XSS | `textContent` or sanitized component |
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Sharing Model — Reference
|
|
2
|
+
|
|
3
|
+
> Source: <https://architect.salesforce.com/fundamentals/platform-sharing-architecture>
|
|
4
|
+
> Last verified: API v66.0, Spring '26 (2026-03-28)
|
|
5
|
+
|
|
6
|
+
## Apex Sharing Keywords
|
|
7
|
+
|
|
8
|
+
| Keyword | Enforcement | Behavior |
|
|
9
|
+
|---|---|---|
|
|
10
|
+
| `with sharing` | User mode | Enforces OWD, role hierarchy, sharing rules, manual shares for running user |
|
|
11
|
+
| `without sharing` | System mode | Ignores all sharing rules; returns all records the user has object-level access to |
|
|
12
|
+
| `inherited sharing` | Caller's mode | Inherits sharing context of the calling class; defaults to `with sharing` if entry point |
|
|
13
|
+
| _(omitted)_ | Varies | Runs as `without sharing` **unless** called from a `with sharing` class (then inherits) |
|
|
14
|
+
|
|
15
|
+
**Special contexts:**
|
|
16
|
+
|
|
17
|
+
| Context | Default Sharing Mode |
|
|
18
|
+
|---|---|
|
|
19
|
+
| Triggers | `without sharing` (system mode); call `with sharing` class to enforce |
|
|
20
|
+
| Anonymous Apex | `with sharing` enforced by default |
|
|
21
|
+
| Inner classes | Do **not** inherit outer class keyword; must declare their own |
|
|
22
|
+
| Visualforce controllers | Standard controller: `with sharing`; custom controller: depends on keyword |
|
|
23
|
+
|
|
24
|
+
## Organization-Wide Defaults (OWD)
|
|
25
|
+
|
|
26
|
+
OWD sets the **most restrictive** baseline. Additional mechanisms only open access further.
|
|
27
|
+
|
|
28
|
+
| Level | Visibility | Edit | Transfer |
|
|
29
|
+
|---|---|---|---|
|
|
30
|
+
| **Private** | Owner + hierarchy above | Owner + hierarchy above | Owner |
|
|
31
|
+
| **Public Read Only** | All users | Owner + hierarchy above | Owner |
|
|
32
|
+
| **Public Read/Write** | All users | All users | Owner |
|
|
33
|
+
| **Public Read/Write/Transfer** | All users | All users | All users |
|
|
34
|
+
| **Controlled by Parent** | Inherited from parent record | Inherited from parent record | N/A |
|
|
35
|
+
|
|
36
|
+
### Object-Specific OWD Options
|
|
37
|
+
|
|
38
|
+
| Object | Available OWD Levels |
|
|
39
|
+
|---|---|
|
|
40
|
+
| Account | Private, Public Read Only, Public Read/Write |
|
|
41
|
+
| Contact | Controlled by Parent, Private, Public Read Only, Public Read/Write |
|
|
42
|
+
| Opportunity | Private, Public Read Only, Public Read/Write |
|
|
43
|
+
| Case | Private, Public Read Only, Public Read/Write, Public Read/Write/Transfer |
|
|
44
|
+
| Lead | Private, Public Read Only, Public Read/Write, Public Read/Write/Transfer |
|
|
45
|
+
| Campaign | Private, Public Read Only, Public Full Access |
|
|
46
|
+
| Price Book | No Access, View Only, Use |
|
|
47
|
+
| Custom Objects | Private, Public Read Only, Public Read/Write |
|
|
48
|
+
|
|
49
|
+
- **External OWD:** Separate baseline for portal/community users; must be equal to or more restrictive than internal OWD.
|
|
50
|
+
- **Grant Access Using Hierarchies:** Checkbox on custom objects (default on); when disabled, role hierarchy does not auto-grant access.
|
|
51
|
+
|
|
52
|
+
## Record Access Mechanisms (Evaluation Order)
|
|
53
|
+
|
|
54
|
+
| # | Mechanism | Description |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| 1 | **OWD** | Baseline for all users |
|
|
57
|
+
| 2 | **Role Hierarchy** | Managers inherit subordinate record access (unless disabled for custom objects) |
|
|
58
|
+
| 3 | **Owner-Based Sharing Rules** | Share records owned by role/group A with role/group B |
|
|
59
|
+
| 4 | **Criteria-Based Sharing Rules** | Share records matching field criteria with role/group |
|
|
60
|
+
| 5 | **Teams** | Account Teams, Opportunity Teams, Case Teams |
|
|
61
|
+
| 6 | **Territory Management** | Access based on territory assignment |
|
|
62
|
+
| 7 | **Manual Sharing** | Ad-hoc grant by record owner or admin; **removed on owner change** |
|
|
63
|
+
| 8 | **Apex Managed Sharing** | Programmatic share rows with custom RowCause; **survives owner change** |
|
|
64
|
+
| 9 | **Restriction Rules** | Filters that further **limit** visibility (2-5 per object) |
|
|
65
|
+
|
|
66
|
+
## Sharing Rule Types
|
|
67
|
+
|
|
68
|
+
| Type | Shares Based On | Access Granted | Limit |
|
|
69
|
+
|---|---|---|---|
|
|
70
|
+
| **Owner-Based** | Record owner (role, group, territory, queue) | Read Only or Read/Write | 300 per object |
|
|
71
|
+
| **Criteria-Based** | Field values on record | Read Only or Read/Write | 50 per object |
|
|
72
|
+
| **Guest User** | Field values (criteria-based) | Read Only **only** | Included in criteria limit |
|
|
73
|
+
|
|
74
|
+
## Implicit Sharing (Non-Configurable)
|
|
75
|
+
|
|
76
|
+
| Type | Behavior |
|
|
77
|
+
|---|---|
|
|
78
|
+
| **Parent Implicit** | Access to child (Contact, Opp, Case) grants read-only on parent Account |
|
|
79
|
+
| **Child Implicit** | Account owner gets access to child records per role-level settings |
|
|
80
|
+
|
|
81
|
+
## Share Object (`__Share`) Structure — `MyObject__Share` (custom) / `AccountShare` (standard)
|
|
82
|
+
|
|
83
|
+
| Field | Description | Values |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| `ParentId` | ID of the record being shared | Record ID |
|
|
86
|
+
| `UserOrGroupId` | User, Group, or Queue receiving access | User/Group ID |
|
|
87
|
+
| `AccessLevel` | Level of access granted | `Read`, `Edit`, `All` |
|
|
88
|
+
| `RowCause` | Reason for the share row | See table below |
|
|
89
|
+
|
|
90
|
+
### RowCause Values
|
|
91
|
+
|
|
92
|
+
| RowCause | Description |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `Owner` | Record owner (system-managed) |
|
|
95
|
+
| `Manual` | Manual sharing or Apex sharing on standard objects |
|
|
96
|
+
| `Rule` | Sharing rule |
|
|
97
|
+
| `ImplicitChild` | Child implicit sharing |
|
|
98
|
+
| `ImplicitParent` | Parent implicit sharing |
|
|
99
|
+
| `Team` | Team member sharing |
|
|
100
|
+
| `TerritoryRule` | Territory-based sharing |
|
|
101
|
+
| `Territory2Forecast` | Enterprise territory forecast sharing |
|
|
102
|
+
| _(Custom reason)_ | Apex sharing reason (custom objects only) |
|
|
103
|
+
|
|
104
|
+
- Custom `RowCause` values require Setup > Object > Apex Sharing Reasons
|
|
105
|
+
- Only available on **custom objects**; standard objects must use `Manual`
|
|
106
|
+
- `Manual` shares are **deleted on owner change**; custom reasons **survive** owner change
|
|
107
|
+
- Insert/delete `__Share` rows in `without sharing` context
|
|
108
|
+
- Sharing recalculation: implement `Database.Batchable` to rebuild shares at scale
|
|
109
|
+
|
|
110
|
+
## Limits
|
|
111
|
+
|
|
112
|
+
| Limit | Value |
|
|
113
|
+
|---|---|
|
|
114
|
+
| Roles (internal / external) | 25,000 / 100,000 |
|
|
115
|
+
| Role hierarchy branch depth | 10 levels recommended |
|
|
116
|
+
| Public groups / nesting depth | 100,000 / 5 levels |
|
|
117
|
+
| Owner-based sharing rules per object | 300 |
|
|
118
|
+
| Criteria-based sharing rules per object | 50 |
|
|
119
|
+
| Restriction rules per object | 2-5 (edition-dependent) |
|
|
120
|
+
| Ownership skew threshold | 10,000 records per user |
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# SOQL Patterns — Reference
|
|
2
|
+
|
|
3
|
+
> Source: <https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql.htm>
|
|
4
|
+
> Last verified: API v66.0, Spring '26 (2026-03-28)
|
|
5
|
+
|
|
6
|
+
## Query Selectivity
|
|
7
|
+
|
|
8
|
+
The Force.com query optimizer evaluates every WHERE filter against selectivity thresholds. If no filter is selective, the query does a full table scan (and fails on objects >200 000 rows in triggers).
|
|
9
|
+
|
|
10
|
+
### Selectivity Thresholds
|
|
11
|
+
|
|
12
|
+
| Index Type | First 1M Records | Records Beyond 1M | Max Target Rows |
|
|
13
|
+
|---|---|---|---|
|
|
14
|
+
| Standard index | < 30% | < 15% | 1,000,000 |
|
|
15
|
+
| Custom index | < 10% | < 5% | 333,333 |
|
|
16
|
+
|
|
17
|
+
A filter is **selective** when targeted rows fall below the threshold. Multiple non-selective AND filters can combine to be selective if their intersection is below the threshold.
|
|
18
|
+
|
|
19
|
+
### Optimizable vs Non-Optimizable Operators
|
|
20
|
+
|
|
21
|
+
| Optimizable | Non-Optimizable |
|
|
22
|
+
|---|---|
|
|
23
|
+
| `=`, `<`, `>`, `<=`, `>=` | `!=`, `NOT` |
|
|
24
|
+
| `IN`, `LIKE` (leading-% excluded) | `NOT IN`, `EXCLUDES` |
|
|
25
|
+
| `INCLUDES` | `LIKE 'abc%def'` (leading wildcard) |
|
|
26
|
+
|
|
27
|
+
### Standard Indexed Fields (Auto-Created)
|
|
28
|
+
|
|
29
|
+
| Field | Notes |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `Id` | Primary key |
|
|
32
|
+
| `Name` | Compound name fields on standard objects |
|
|
33
|
+
| `OwnerId` | Lookup to User/Group |
|
|
34
|
+
| `RecordTypeId` | |
|
|
35
|
+
| `CreatedDate` | |
|
|
36
|
+
| `SystemModstamp` | Preferred over `LastModifiedDate` for filtering |
|
|
37
|
+
| `LastModifiedDate` | Shares index with `SystemModstamp` internally |
|
|
38
|
+
| Lookup / Master-Detail fields | All relationship foreign keys |
|
|
39
|
+
| `Email` | On Contact and Lead only |
|
|
40
|
+
| `Division` | If multi-division enabled |
|
|
41
|
+
| External ID fields | Index auto-created when field marked External ID |
|
|
42
|
+
|
|
43
|
+
**Non-indexable types:** Multi-select picklist, Long text area, Rich text area, Encrypted text, Non-deterministic formula fields.
|
|
44
|
+
|
|
45
|
+
## Relationship Query Limits
|
|
46
|
+
|
|
47
|
+
| Constraint | Limit |
|
|
48
|
+
|---|---|
|
|
49
|
+
| Child-to-parent levels (dot notation) | 5 |
|
|
50
|
+
| Parent-to-child subqueries per query | 20 |
|
|
51
|
+
| Child-to-parent relationships per query | 55 |
|
|
52
|
+
| Records returned per subquery | 2,000 |
|
|
53
|
+
| Parent-to-child nesting (REST/SOAP, API v58.0+) | 5 levels |
|
|
54
|
+
| Parent-to-child nesting (Apex) | 2 levels |
|
|
55
|
+
|
|
56
|
+
## Aggregate Query Rules
|
|
57
|
+
|
|
58
|
+
| Function | Field Types Supported |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `COUNT()` | All (no field argument) |
|
|
61
|
+
| `COUNT(field)` | All except long text, rich text |
|
|
62
|
+
| `COUNT_DISTINCT(field)` | All except long text, rich text |
|
|
63
|
+
| `SUM(field)` | Number, Currency, Percent |
|
|
64
|
+
| `AVG(field)` | Number, Currency, Percent |
|
|
65
|
+
| `MIN(field)` | Number, Currency, Percent, Date, Datetime |
|
|
66
|
+
| `MAX(field)` | Number, Currency, Percent, Date, Datetime |
|
|
67
|
+
|
|
68
|
+
| Constraint | Value |
|
|
69
|
+
|---|---|
|
|
70
|
+
| Max grouped rows returned | 2,000 |
|
|
71
|
+
| Max fields in `GROUP BY` | 3 (with ROLLUP/CUBE) |
|
|
72
|
+
| `GROUP BY ROLLUP` | Supported (API v18.0+) |
|
|
73
|
+
| `GROUP BY CUBE` | Supported (API v18.0+) |
|
|
74
|
+
| `HAVING` | Filters on aggregate result only |
|
|
75
|
+
| `TYPEOF` with GROUP BY | Not supported |
|
|
76
|
+
|
|
77
|
+
## SOQL Keyword Reference
|
|
78
|
+
|
|
79
|
+
Core syntax: `SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... ORDER BY ... [ASC|DESC] [NULLS FIRST|LAST] LIMIT n OFFSET n` (OFFSET max 2,000).
|
|
80
|
+
|
|
81
|
+
### Scope, Security & Locking Clauses
|
|
82
|
+
|
|
83
|
+
| Clause | Purpose | Constraints |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| `FOR UPDATE` | Row-level pessimistic lock (10 s timeout) | No ORDER BY; no aggregates; max 200 rows |
|
|
86
|
+
| `FOR VIEW` | Updates `RecentlyViewed` | Informational; no query behavior change |
|
|
87
|
+
| `FOR REFERENCE` | Updates `RecentlyViewed` for related records | Informational; no query behavior change |
|
|
88
|
+
| `WITH SECURITY_ENFORCED` | Enforce FLS in SELECT (legacy) | SELECT only; throws on violation |
|
|
89
|
+
| `WITH USER_MODE` | Full CRUD + FLS + sharing (recommended) | Works in DML too; API v60.0+ |
|
|
90
|
+
| `WITH SYSTEM_MODE` | Bypass all security | Works in DML too; API v60.0+ |
|
|
91
|
+
| `USING SCOPE scope` | Restrict record scope | Values: `Everything`, `Mine`, `Queue`, `Delegated`, `MyTerritory`, `MyTeamTerritory`, `Team` |
|
|
92
|
+
|
|
93
|
+
### TYPEOF (Polymorphic Relationships)
|
|
94
|
+
|
|
95
|
+
Syntax: `TYPEOF field WHEN Type1 THEN fields WHEN Type2 THEN fields ELSE fields END`. Filter with `WHERE field.Type IN (...)`. Cannot combine with: `GROUP BY`, `ROLLUP`, `CUBE`, `HAVING`, `COUNT()`.
|
|
96
|
+
|
|
97
|
+
## SOQL Cursor Pagination (API v66.0+)
|
|
98
|
+
|
|
99
|
+
| Constraint | Value |
|
|
100
|
+
|---|---|
|
|
101
|
+
| Max records per cursor | 50,000,000 |
|
|
102
|
+
| `fetch()` max page size | 2,000 rows |
|
|
103
|
+
| Max `fetch()` calls per transaction | 10 |
|
|
104
|
+
| Max cursors per day (org-wide) | 10,000 |
|
|
105
|
+
| Max rows per day (org-wide, aggregate) | 100,000,000 |
|
|
106
|
+
| Cursor lifetime (sync) | 10 minutes |
|
|
107
|
+
| Cursor lifetime (async) | 60 minutes |
|
|
108
|
+
|
|
109
|
+
API: `Database.getCursor(soqlString)` returns `Database.Cursor`. Use `cursor.fetch(offset, count)` and `cursor.getNumRecords()`.
|
|
110
|
+
|
|
111
|
+
## SOQL Governor Limits (Quick Ref)
|
|
112
|
+
|
|
113
|
+
| Resource | Synchronous | Asynchronous |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| SOQL queries per transaction | 100 | 200 |
|
|
116
|
+
| Total rows returned | 50,000 | 50,000 |
|
|
117
|
+
| `FOR UPDATE` max rows | 200 | 200 |
|
|
118
|
+
| OFFSET max value | 2,000 | 2,000 |
|
|
119
|
+
| QueryLocator rows (Batch) | N/A | 50,000,000 |
|