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,278 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-data-modeling
|
|
3
|
+
description: >-
|
|
4
|
+
Use when designing Salesforce custom objects, relationships, Custom Metadata,
|
|
5
|
+
or sharing models for scalable org architecture.
|
|
6
|
+
Do NOT use for SOQL optimization or Apex patterns.
|
|
7
|
+
origin: SCC
|
|
8
|
+
user-invocable: false
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Salesforce Data Modeling
|
|
12
|
+
|
|
13
|
+
@../_reference/DATA_MODELING.md
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
- Designing new custom objects, fields, or relationships
|
|
18
|
+
- Deciding between lookup vs master-detail relationships
|
|
19
|
+
- Planning record types, page layouts, or sharing model architecture
|
|
20
|
+
- Architecting for large data volumes (LDV) requiring index-aware field design
|
|
21
|
+
- Reviewing or refactoring an existing data model
|
|
22
|
+
- Evaluating external objects, custom metadata types, or hierarchical settings
|
|
23
|
+
|
|
24
|
+
## Object Design Principles
|
|
25
|
+
|
|
26
|
+
### Extend Standard Objects When Possible
|
|
27
|
+
|
|
28
|
+
| Business Need | Use Standard Object | Not Custom |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| Customer companies | Account | Company__c |
|
|
31
|
+
| Individual contacts | Contact | Person__c |
|
|
32
|
+
| Sales deals | Opportunity | Deal__c |
|
|
33
|
+
| Support tickets | Case | Ticket__c |
|
|
34
|
+
| Events/meetings | Event | Meeting__c |
|
|
35
|
+
| Tasks/to-dos | Task | Todo__c |
|
|
36
|
+
| Products/pricing | Product2, PricebookEntry | Product__c |
|
|
37
|
+
| Orders | Order, OrderItem | PurchaseOrder__c |
|
|
38
|
+
|
|
39
|
+
Standard objects come with built-in reports, process automations, and integrations.
|
|
40
|
+
|
|
41
|
+
### Custom Object Naming
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
API Name: ProjectTask__c (PascalCase + __c)
|
|
45
|
+
Label: Project Task (human-readable)
|
|
46
|
+
Plural: Project Tasks
|
|
47
|
+
Relationship Name: ProjectTasks (plural for child relationship)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Relationship Types
|
|
53
|
+
|
|
54
|
+
| Relationship | Cascade Delete | Roll-Up Summary | Required | Sharing Inherited |
|
|
55
|
+
|---|---|---|---|---|
|
|
56
|
+
| Lookup | No (configurable) | No | No | No |
|
|
57
|
+
| Master-Detail | Yes | Yes | Yes | Yes |
|
|
58
|
+
| Many-to-Many (Junction) | Both sides | From junction | Both | From primary master |
|
|
59
|
+
| Hierarchical | No | No | No | No |
|
|
60
|
+
| External Lookup | No | No | No | No |
|
|
61
|
+
|
|
62
|
+
*Master-Detail can be reparented if "Allow Reparenting" is enabled.
|
|
63
|
+
|
|
64
|
+
### When to Use Lookup
|
|
65
|
+
|
|
66
|
+
- Child can exist independently (Contact without Account)
|
|
67
|
+
- No roll-up summaries needed
|
|
68
|
+
- Child needs its own sharing settings
|
|
69
|
+
- Multiple lookups, none is primary
|
|
70
|
+
|
|
71
|
+
### When to Use Master-Detail
|
|
72
|
+
|
|
73
|
+
- Child has no meaning without parent (Order Line Item without Order)
|
|
74
|
+
- Roll-up summary fields needed on parent
|
|
75
|
+
- Child deleted when parent deleted
|
|
76
|
+
- Child sharing inherits from parent
|
|
77
|
+
|
|
78
|
+
```xml
|
|
79
|
+
<!-- Master-Detail field metadata -->
|
|
80
|
+
<fields>
|
|
81
|
+
<fullName>Project__c</fullName>
|
|
82
|
+
<label>Project</label>
|
|
83
|
+
<type>MasterDetail</type>
|
|
84
|
+
<referenceTo>Project__c</referenceTo>
|
|
85
|
+
<relationshipLabel>Project Tasks</relationshipLabel>
|
|
86
|
+
<relationshipName>ProjectTasks</relationshipName>
|
|
87
|
+
<relationshipOrder>0</relationshipOrder>
|
|
88
|
+
<reparentableMasterDetail>false</reparentableMasterDetail>
|
|
89
|
+
</fields>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Field Type Guide
|
|
95
|
+
|
|
96
|
+
| Field Type | Use When | Avoid When |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| Text (255) | Short single-line text | Long descriptions |
|
|
99
|
+
| Long Text Area | Up to 131,072 chars | Need to filter/search on it |
|
|
100
|
+
| Rich Text Area | HTML-formatted content | Need to query/filter by content |
|
|
101
|
+
| Number | Integers, no currency | Financial values (use Currency) |
|
|
102
|
+
| Currency | Monetary values | Non-financial numbers |
|
|
103
|
+
| Date | Date without time | Need time zone info |
|
|
104
|
+
| DateTime | Timestamps, audit trails | Simple date records |
|
|
105
|
+
| Checkbox | Boolean yes/no | Optional boolean (use Picklist) |
|
|
106
|
+
| Picklist (single) | Controlled vocabulary | Many values (use Lookup) |
|
|
107
|
+
| Picklist (multi) | Multiple selections | Filtering/reporting (anti-pattern) |
|
|
108
|
+
| Formula | Calculated, read-only | Values needing DML update |
|
|
109
|
+
| Roll-Up Summary | Aggregate child data | 25 per object (default limit) |
|
|
110
|
+
| External ID | Upsert key from external system | - |
|
|
111
|
+
|
|
112
|
+
### Multi-Select Picklist Warning
|
|
113
|
+
|
|
114
|
+
```apex
|
|
115
|
+
// Limited SOQL support — can use INCLUDES/EXCLUDES but not = or IN
|
|
116
|
+
List<Case> cases = [
|
|
117
|
+
SELECT Id FROM Case
|
|
118
|
+
WHERE Tag_List__c INCLUDES ('Billing', 'Technical')
|
|
119
|
+
];
|
|
120
|
+
// Cannot use in GROUP BY, ORDER BY, or most aggregates
|
|
121
|
+
// Consider Lookup to a Tags junction object for complex tagging
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Custom Metadata Types vs Custom Settings vs Custom Labels
|
|
127
|
+
|
|
128
|
+
| Feature | Custom Metadata | Custom Settings | Custom Labels |
|
|
129
|
+
|---|---|---|---|
|
|
130
|
+
| Deployable | Yes | No (hierarchy)/Yes (list) | Yes |
|
|
131
|
+
| Per-user/profile values | No | Yes (hierarchy) | No |
|
|
132
|
+
| Governor limit on reads | No (cached) | Yes (SOQL equivalent) | No |
|
|
133
|
+
| Best for | Config deployed with code | User/profile-specific settings | Translatable strings |
|
|
134
|
+
|
|
135
|
+
```apex
|
|
136
|
+
// Custom Metadata — no SOQL limits, deployable
|
|
137
|
+
String endpoint = Service_Config__mdt.getInstance('Production').Endpoint_URL__c;
|
|
138
|
+
|
|
139
|
+
// Custom Setting — profile-specific
|
|
140
|
+
Boolean isEnabled = Integration_Settings__c.getInstance().Is_Enabled__c;
|
|
141
|
+
|
|
142
|
+
// Custom Label — translatable
|
|
143
|
+
String welcomeMsg = System.Label.Welcome_Message;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Record Types
|
|
149
|
+
|
|
150
|
+
### When to Use
|
|
151
|
+
|
|
152
|
+
- Different page layouts per user group
|
|
153
|
+
- Different picklist values per business process
|
|
154
|
+
- Different automation processes per record type
|
|
155
|
+
|
|
156
|
+
### When NOT to Use
|
|
157
|
+
|
|
158
|
+
- Simple field-level differences (use conditional visibility)
|
|
159
|
+
- Access control (use sharing rules or permission sets)
|
|
160
|
+
- Fundamentally different data structures (use separate objects)
|
|
161
|
+
|
|
162
|
+
```apex
|
|
163
|
+
Id caseRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName()
|
|
164
|
+
.get('Internal_Support').getRecordTypeId();
|
|
165
|
+
|
|
166
|
+
List<Case> internalCases = [
|
|
167
|
+
SELECT Id, Subject FROM Case
|
|
168
|
+
WHERE RecordTypeId = :caseRecordTypeId WITH USER_MODE
|
|
169
|
+
];
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Sharing Model Design
|
|
175
|
+
|
|
176
|
+
### Object-Wide Defaults (OWD)
|
|
177
|
+
|
|
178
|
+
| OWD Setting | Other Users | Best For |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| Public Read/Write | Read + Write | Reference/config data |
|
|
181
|
+
| Public Read Only | Read only | Products, pricebooks |
|
|
182
|
+
| Private | None | Accounts, Opportunities |
|
|
183
|
+
| Controlled by Parent | Inherits | Master-Detail children |
|
|
184
|
+
|
|
185
|
+
Start with Private OWD for sensitive objects and open up with sharing rules.
|
|
186
|
+
|
|
187
|
+
### Apex Managed Sharing
|
|
188
|
+
|
|
189
|
+
```apex
|
|
190
|
+
public with sharing class ProjectSharingService {
|
|
191
|
+
public static void shareProjectWithUser(Id projectId, Id userId, String accessLevel) {
|
|
192
|
+
Project__Share shareRecord = new Project__Share(
|
|
193
|
+
ParentId = projectId,
|
|
194
|
+
UserOrGroupId = userId,
|
|
195
|
+
AccessLevel = accessLevel,
|
|
196
|
+
RowCause = Schema.Project__Share.RowCause.Manual
|
|
197
|
+
);
|
|
198
|
+
Database.SaveResult result = Database.insert(shareRecord, false);
|
|
199
|
+
if (!result.isSuccess() &&
|
|
200
|
+
result.getErrors()[0].getStatusCode() != StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION) {
|
|
201
|
+
throw new SharingException('Failed to share: ' + result.getErrors()[0].getMessage());
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
public class SharingException extends Exception {}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Large Data Volume (LDV) Considerations
|
|
211
|
+
|
|
212
|
+
Objects with >100,000 records require special attention.
|
|
213
|
+
|
|
214
|
+
**Schema design:**
|
|
215
|
+
|
|
216
|
+
- Add external ID fields on objects queried by non-Id values
|
|
217
|
+
- Request custom indexes on fields used in WHERE clauses
|
|
218
|
+
- Consider skinny tables for frequently-accessed field subsets
|
|
219
|
+
- Avoid Roll-Up Summary fields on LDV child objects (use batch triggers instead)
|
|
220
|
+
|
|
221
|
+
```apex
|
|
222
|
+
// Good — uses indexed fields, selective
|
|
223
|
+
List<Order__c> orders = [
|
|
224
|
+
SELECT Id, Status__c FROM Order__c
|
|
225
|
+
WHERE AccountId = :accountId
|
|
226
|
+
AND CreatedDate >= :thirtyDaysAgo
|
|
227
|
+
LIMIT 200
|
|
228
|
+
];
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Archiving:** Move old records to BigObjects or external archive. Use batch jobs for archive-and-delete.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Junction Object Patterns
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
Account <-- AccountContactRelation --> Contact
|
|
239
|
+
+ Role (picklist)
|
|
240
|
+
+ IsPrimary (checkbox)
|
|
241
|
+
+ StartDate (date)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
- Junction objects with Master-Detail on both sides inherit sharing from BOTH parents
|
|
245
|
+
- Add meaningful fields to the junction (Role, Start Date, Status)
|
|
246
|
+
- Use `AccountContactRelation` (standard) before creating custom junctions for Account-Contact
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## External Object Patterns
|
|
251
|
+
|
|
252
|
+
| Adapter | Use When |
|
|
253
|
+
|---|---|
|
|
254
|
+
| OData 2.0/4.0 | External REST API with OData support |
|
|
255
|
+
| Custom Adapter | Proprietary API or database |
|
|
256
|
+
| Cross-Org | Another Salesforce org |
|
|
257
|
+
|
|
258
|
+
External Objects have no triggers, Flows, or Validation Rules. Use Apex callouts for write operations.
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Anti-Patterns
|
|
263
|
+
|
|
264
|
+
| Anti-Pattern | Fix |
|
|
265
|
+
|---|---|
|
|
266
|
+
| Polymorphic lookup abuse | Use explicit lookup fields per related object |
|
|
267
|
+
| Over-normalization | Flatten into fields unless multiple addresses per record |
|
|
268
|
+
| Too many custom fields (800 limit) | Split into related child objects |
|
|
269
|
+
| Circular Master-Detail | Break the circle with a Lookup on one side |
|
|
270
|
+
| Text instead of Lookup | Use Lookup fields for referential integrity |
|
|
271
|
+
| Ignoring LDV on 100K+ objects | Request custom indexes, use skinny tables |
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Related
|
|
276
|
+
|
|
277
|
+
- **Agent**: `sf-architect` — For interactive, in-depth guidance
|
|
278
|
+
- **Constraints**: `sf-apex-constraints` — Governor limits and Apex safety rules
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-debugging
|
|
3
|
+
description: "Salesforce debugging — debug logs, SOQL explain plan, Flow debug, LWC DevTools, error resolution. Use when diagnosing Apex exceptions, governor breaches, or Flow failures. Do NOT use for tests or build errors."
|
|
4
|
+
origin: SCC
|
|
5
|
+
user-invocable: false
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Salesforce Debugging Techniques
|
|
9
|
+
|
|
10
|
+
Reference: @../_reference/DEBUGGING_TOOLS.md
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- When an Apex exception occurs and you need to trace it through logs
|
|
15
|
+
- When a governor limit is being exceeded and you need the root cause
|
|
16
|
+
- When a Flow or Process Builder is failing silently or producing unexpected results
|
|
17
|
+
- When an LWC component is not rendering data or throwing JavaScript errors
|
|
18
|
+
- When a callout is failing and you need to inspect request/response payloads
|
|
19
|
+
- When onboarding to a new org and diagnosing pre-existing error patterns
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Debug Log Setup
|
|
24
|
+
|
|
25
|
+
### Enabling Debug Logging
|
|
26
|
+
|
|
27
|
+
**Via SF CLI (stream live logs):**
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Stream all logs for the org in real time
|
|
31
|
+
sf apex tail log --target-org myOrg
|
|
32
|
+
|
|
33
|
+
# Stream logs with specific debug level
|
|
34
|
+
sf apex tail log \
|
|
35
|
+
--target-org myOrg \
|
|
36
|
+
--debug-level SFDC_DevConsole
|
|
37
|
+
|
|
38
|
+
# Retrieve a specific log by ID
|
|
39
|
+
sf apex get log \
|
|
40
|
+
--log-id 07L5e000000XXXXX \
|
|
41
|
+
--target-org myOrg
|
|
42
|
+
|
|
43
|
+
# List recent logs
|
|
44
|
+
sf apex list log --target-org myOrg
|
|
45
|
+
|
|
46
|
+
# Run anonymous Apex and capture log
|
|
47
|
+
sf apex run \
|
|
48
|
+
--file scripts/apex/debug-script.apex \
|
|
49
|
+
--target-org myOrg
|
|
50
|
+
|
|
51
|
+
# Run and save full log
|
|
52
|
+
sf apex run \
|
|
53
|
+
--file scripts/apex/debug-script.apex \
|
|
54
|
+
--target-org myOrg > debug-output.txt
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Via Setup UI:**
|
|
58
|
+
|
|
59
|
+
1. Setup > Debug Logs (under Environments)
|
|
60
|
+
2. Click "New" under Monitored Users
|
|
61
|
+
3. Select user, set expiration and log level
|
|
62
|
+
4. Reproduce the issue
|
|
63
|
+
5. Click the log entry to open it
|
|
64
|
+
|
|
65
|
+
**Via Developer Console:**
|
|
66
|
+
|
|
67
|
+
1. Open: `sf org open --target-org myOrg`
|
|
68
|
+
2. Click "Developer Console" (gear icon or App Launcher)
|
|
69
|
+
3. Debug > Change Log Levels
|
|
70
|
+
4. Set user-specific debug levels
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Reading Debug Logs
|
|
75
|
+
|
|
76
|
+
Debug logs have a maximum size of 20 MB. Logs exceeding this are truncated from the middle. If you see gaps, reduce log level verbosity or narrow the operation scope.
|
|
77
|
+
|
|
78
|
+
### Key Sections in a Log
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
15:23:01.001 (1234567)|EXECUTION_STARTED
|
|
82
|
+
15:23:01.012 (12345678)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
|
|
83
|
+
15:23:01.015 (15000000)|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|SELECT Id FROM Account
|
|
84
|
+
15:23:01.045 (45000000)|SOQL_EXECUTE_END|[12]|Rows:150
|
|
85
|
+
15:23:01.050 (50000000)|USER_DEBUG|[15]|DEBUG|Processing 150 accounts
|
|
86
|
+
15:23:01.200 (200000000)|DML_BEGIN|[22]|Op:Insert|Type:Contact|Rows:150
|
|
87
|
+
15:23:01.350 (350000000)|DML_END|[22]
|
|
88
|
+
15:23:01.400 (400000000)|CUMULATIVE_LIMIT_USAGE
|
|
89
|
+
Number of SOQL queries: 3 out of 100
|
|
90
|
+
Number of DML rows: 150 out of 10000
|
|
91
|
+
Maximum CPU time: 452 out of 10000
|
|
92
|
+
15:23:01.401 (401000000)|EXECUTION_FINISHED
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Finding CPU Hogs
|
|
96
|
+
|
|
97
|
+
Compare timestamps between BEGIN/END pairs to identify slow operations:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Find slow operations by comparing BEGIN/END timestamps
|
|
101
|
+
grep -E "SOQL_EXECUTE_BEGIN|SOQL_EXECUTE_END|DML_BEGIN|DML_END" debug.log
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Developer Console
|
|
107
|
+
|
|
108
|
+
### Anonymous Apex Execution
|
|
109
|
+
|
|
110
|
+
```apex
|
|
111
|
+
// Open Developer Console > Execute Anonymous (Ctrl+E / Cmd+E)
|
|
112
|
+
Account acc = [SELECT Id FROM Account WHERE Name = 'Test Corp' LIMIT 1];
|
|
113
|
+
AccountService svc = new AccountService();
|
|
114
|
+
AccountService.AccountResult result = svc.getAccount(acc.Id);
|
|
115
|
+
System.debug(LoggingLevel.ERROR, JSON.serializePretty(result));
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Query Editor
|
|
119
|
+
|
|
120
|
+
```sql
|
|
121
|
+
-- Developer Console > Query Editor tab
|
|
122
|
+
SELECT Id, Name, StageName, Amount, CloseDate
|
|
123
|
+
FROM Opportunity
|
|
124
|
+
WHERE StageName = 'Negotiation'
|
|
125
|
+
AND CloseDate = THIS_QUARTER
|
|
126
|
+
ORDER BY Amount DESC
|
|
127
|
+
LIMIT 25
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Use "Query Plan" button to analyse query performance (see SOQL Query Plan section below).
|
|
131
|
+
|
|
132
|
+
### Checkpoints (Heap Inspection)
|
|
133
|
+
|
|
134
|
+
1. Debug > Add/Remove Checkpoint (on a code line)
|
|
135
|
+
2. Execute code that runs through the checkpointed line
|
|
136
|
+
3. Debug > Checkpoint Inspector -- see heap contents, variable values
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## SOQL Query Plan (Explain Plan)
|
|
141
|
+
|
|
142
|
+
### How to Access
|
|
143
|
+
|
|
144
|
+
1. Developer Console > Query Editor
|
|
145
|
+
2. Write your query
|
|
146
|
+
3. Click "Query Plan" button (not "Execute")
|
|
147
|
+
|
|
148
|
+
### Optimising Based on Plan
|
|
149
|
+
|
|
150
|
+
```soql
|
|
151
|
+
-- BAD: Cost = 2.5 (TableScan)
|
|
152
|
+
SELECT Id FROM Account WHERE Description LIKE '%enterprise%'
|
|
153
|
+
|
|
154
|
+
-- GOOD: Cost = 0.1 (Index on ExternalId__c)
|
|
155
|
+
SELECT Id FROM Account WHERE ExternalId__c = 'ACC-001'
|
|
156
|
+
|
|
157
|
+
-- GOOD: Cost = 0.3 (Index on OwnerId)
|
|
158
|
+
SELECT Id FROM Account WHERE OwnerId = :currentUserId
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## VS Code Apex Debugger
|
|
164
|
+
|
|
165
|
+
### Apex Replay Debugger (Free)
|
|
166
|
+
|
|
167
|
+
Available in all editions with the Salesforce Extension Pack:
|
|
168
|
+
|
|
169
|
+
1. Capture a debug log (via SF CLI, Developer Console, or Setup)
|
|
170
|
+
2. Open the `.log` file in VS Code
|
|
171
|
+
3. Command Palette: "SFDX: Launch Apex Replay Debugger with Current File"
|
|
172
|
+
4. Set breakpoints in `.cls` files
|
|
173
|
+
5. Step through execution, inspect variables and the call stack
|
|
174
|
+
|
|
175
|
+
### Interactive Apex Debugger (Paid)
|
|
176
|
+
|
|
177
|
+
Requires Performance Edition, Unlimited Edition, or Enterprise Edition add-on. Not available in Developer Edition.
|
|
178
|
+
|
|
179
|
+
#### Launch Configuration
|
|
180
|
+
|
|
181
|
+
```json
|
|
182
|
+
// .vscode/launch.json
|
|
183
|
+
{
|
|
184
|
+
"version": "0.2.0",
|
|
185
|
+
"configurations": [
|
|
186
|
+
{
|
|
187
|
+
"name": "Launch Apex Debugger",
|
|
188
|
+
"type": "apex",
|
|
189
|
+
"request": "launch",
|
|
190
|
+
"userIdFilter": [],
|
|
191
|
+
"requestTypeFilter": [],
|
|
192
|
+
"entryPointFilter": "",
|
|
193
|
+
"salesforceProject": "${workspaceRoot}"
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### Debugging Steps
|
|
200
|
+
|
|
201
|
+
1. Set breakpoints in `.cls` files (click gutter)
|
|
202
|
+
2. Run > Start Debugging (F5) with "Launch Apex Debugger"
|
|
203
|
+
3. Reproduce the action in Salesforce UI
|
|
204
|
+
4. VS Code pauses at breakpoint
|
|
205
|
+
5. Inspect variables, Step Over (F10), Step Into (F11), Continue (F5)
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Common Errors: Root Causes and Fixes
|
|
210
|
+
|
|
211
|
+
### System.LimitException: Too many SOQL queries: 101
|
|
212
|
+
|
|
213
|
+
**Root cause:** SOQL query inside a loop
|
|
214
|
+
|
|
215
|
+
```apex
|
|
216
|
+
// WRONG -- SOQL in loop
|
|
217
|
+
for (Account acc : Trigger.new) {
|
|
218
|
+
List<Contact> contacts = [SELECT Id FROM Contact WHERE AccountId = :acc.Id];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// FIX -- single query outside loop
|
|
222
|
+
Map<Id, List<Contact>> contactsByAccount = new Map<Id, List<Contact>>();
|
|
223
|
+
for (Contact c : [SELECT Id, AccountId FROM Contact WHERE AccountId IN :Trigger.newMap.keySet()]) {
|
|
224
|
+
if (!contactsByAccount.containsKey(c.AccountId)) {
|
|
225
|
+
contactsByAccount.put(c.AccountId, new List<Contact>());
|
|
226
|
+
}
|
|
227
|
+
contactsByAccount.get(c.AccountId).add(c);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Apex CPU time limit exceeded
|
|
232
|
+
|
|
233
|
+
**Root cause:** Complex nested loops, excessive string operations
|
|
234
|
+
|
|
235
|
+
```apex
|
|
236
|
+
// WRONG -- O(n^2) loop
|
|
237
|
+
for (Account acc : accounts) {
|
|
238
|
+
for (Contact con : allContacts) {
|
|
239
|
+
if (con.AccountId == acc.Id) { /* ... */ }
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// FIX -- use Map for O(1) lookup
|
|
244
|
+
Map<Id, List<Contact>> contactsByAccount = buildContactMap(allContacts);
|
|
245
|
+
for (Account acc : accounts) {
|
|
246
|
+
List<Contact> accountContacts = contactsByAccount.get(acc.Id);
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### System.NullPointerException
|
|
251
|
+
|
|
252
|
+
**Root cause:** Unchecked null reference
|
|
253
|
+
|
|
254
|
+
```apex
|
|
255
|
+
// PREFERRED (API 56.0+) -- null-safe navigation
|
|
256
|
+
String upperName = account.Name?.toUpperCase() ?? '';
|
|
257
|
+
String accountName = contact?.Account?.Name ?? 'No Account';
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### UNABLE_TO_LOCK_ROW
|
|
261
|
+
|
|
262
|
+
**Root cause:** Two concurrent transactions updating the same record(s). Fix with retry logic (Queueable), `FOR UPDATE` in SOQL, or reducing batch size.
|
|
263
|
+
|
|
264
|
+
### MIXED_DML_OPERATION
|
|
265
|
+
|
|
266
|
+
**Root cause:** Setup objects (User, Profile) and non-setup objects in the same transaction. Separate with `@future` or `System.runAs()` in tests.
|
|
267
|
+
|
|
268
|
+
### Too many DML rows: 10001
|
|
269
|
+
|
|
270
|
+
**Root cause:** DML on >10,000 records. Use Batch Apex to process in chunks.
|
|
271
|
+
|
|
272
|
+
### Callout from triggers are not supported
|
|
273
|
+
|
|
274
|
+
**Root cause:** Synchronous callout in trigger context. Use `@future(callout=true)`.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Flow Debugging
|
|
279
|
+
|
|
280
|
+
### Flow Debug Mode
|
|
281
|
+
|
|
282
|
+
1. Setup > Flows > Open Flow Builder
|
|
283
|
+
2. Click "Debug" button (top right)
|
|
284
|
+
3. Set input variables and "Run as" user
|
|
285
|
+
4. Click "Run"
|
|
286
|
+
5. Step through elements, inspect variable values
|
|
287
|
+
6. "Rollback" checkbox: undo DML changes during debug
|
|
288
|
+
|
|
289
|
+
### Common Flow Errors
|
|
290
|
+
|
|
291
|
+
| Error | Root Cause | Fix |
|
|
292
|
+
|-------|-----------|-----|
|
|
293
|
+
| "An unhandled fault has occurred" | Missing fault connectors | Add fault paths on all DML/callout elements |
|
|
294
|
+
| Flow SOQL 101 limit exceeded | Get Records inside a loop | Move Get Records outside loop, use Collection Filtering |
|
|
295
|
+
| "This flow can't access the variable" | Variable not marked for input/output | Enable "Available for input/output" on the variable |
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## LWC Debugging
|
|
300
|
+
|
|
301
|
+
### Browser Developer Tools
|
|
302
|
+
|
|
303
|
+
```javascript
|
|
304
|
+
import { LightningElement, wire } from 'lwc';
|
|
305
|
+
|
|
306
|
+
export default class AccountCard extends LightningElement {
|
|
307
|
+
connectedCallback() {
|
|
308
|
+
console.group('AccountCard mounted');
|
|
309
|
+
console.log('accountId:', this.accountId);
|
|
310
|
+
console.groupEnd();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
handleError(error) {
|
|
314
|
+
console.error('AccountCard error:', JSON.stringify(error));
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Enable Lightning Debug Mode
|
|
320
|
+
|
|
321
|
+
1. Setup > Session Settings
|
|
322
|
+
2. Enable "Enable Debug Mode for Lightning Components"
|
|
323
|
+
3. Slower but provides better error messages and unminified source
|
|
324
|
+
|
|
325
|
+
### Chrome Extensions
|
|
326
|
+
|
|
327
|
+
Install "Salesforce Inspector Reloaded" for real-time metadata browsing, direct record access, API Inspector, and SOQL query runner.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## Integration Debugging
|
|
332
|
+
|
|
333
|
+
### Capture Callout Logs
|
|
334
|
+
|
|
335
|
+
```apex
|
|
336
|
+
public class DebugCalloutService {
|
|
337
|
+
public static HttpResponse send(HttpRequest req) {
|
|
338
|
+
System.debug(LoggingLevel.INFO, 'CALLOUT REQUEST: ' + req.getMethod() + ' ' + req.getEndpoint());
|
|
339
|
+
System.debug(LoggingLevel.FINE, 'REQUEST BODY: ' + req.getBody());
|
|
340
|
+
Http http = new Http();
|
|
341
|
+
HttpResponse res = http.send(req);
|
|
342
|
+
System.debug(LoggingLevel.INFO, 'CALLOUT RESPONSE: ' + res.getStatusCode());
|
|
343
|
+
System.debug(LoggingLevel.FINE, 'RESPONSE BODY: ' + res.getBody());
|
|
344
|
+
return res;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Viewing Callout Details in Debug Log
|
|
350
|
+
|
|
351
|
+
With `CALLOUT: FINE` level enabled:
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
CALLOUT_REQUEST|....|POST https://api.example.com/orders
|
|
355
|
+
CALLOUT_RESPONSE|....|200 {"orderId":"123","status":"OK"}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Related
|
|
361
|
+
|
|
362
|
+
- **Agent**: `sf-review-agent` -- for interactive, in-depth guidance
|
|
363
|
+
- **Constraints**: `sf-apex-constraints` -- governor limits and Apex coding rules
|