PranavNagrecha/AwesomeSalesforceSkills / skills/admin/formula-fields
formula-fields
VerifiedUse when designing, reviewing, or troubleshooting Salesforce formula fields. Triggers: 'formula field', 'cross-object formula', 'null handling', 'compile size', 'HYPERLINK', 'IMAGE', 'why is formula slow', 'formulaTreatBlanksAs', 'BlankAsZero', 'blank field handling', 'field-meta.xml formula', 'CustomField formula deploy', 'formula returns blank', 'formula field read-only on data load'. NOT for a formula field slowing a SOQL query or blocking an index — use apex/formula-field-performance-and-limits. NOT for Formula resources inside a Flow — use flow/flow-formula-and-expression-patterns.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 14.2 KB |
| references/examples.md | markdown | 1.4 KB |
| references/gotchas.md | markdown | 9.3 KB |
| references/llm-anti-patterns.md | markdown | 8.6 KB |
| references/metadata-examples.md | markdown | 12.2 KB |
| references/well-architected.md | markdown | 4.3 KB |
| scripts/check_formula_fields.py | script | 8.5 KB |
| templates/formula-field-design-template.md | markdown | 2.4 KB |
references/examples.md
View on GitHub# Examples: Formula Fields
---
## Example: Account Health Status From Multiple Inputs
**Goal:** Show a simple health status to users without storing a separate field.
```text
CASE(
TRUE,
Open_Cases__c > 5, "At Risk",
ARR__c >= 50000 && Last_Activity_Days__c <= 30, "Healthy",
"Monitor"
)
```
**Why this works:** The formula is readable, business-facing, and does not need historical preservation.
---
## Example: Cross-Object Formula for Parent Visibility
**Goal:** Show the parent Account owner on Contact for reporting and page layout convenience.
```text
Account.Owner.Name
```
**Use carefully:** This is fine for display. Do not let a growing set of chained parent references become your reporting architecture.
---
## Example: Defensive Null Handling for Discount Math
**Goal:** Calculate a safe percentage without divide-by-zero behavior.
```text
IF(
OR(ISBLANK(List_Price__c), List_Price__c = 0),
NULL,
(List_Price__c - Net_Price__c) / List_Price__c
)
```
**Why this works:** Blank and zero are handled explicitly, so the formula avoids misleading output.
---
## Example: Link Formula for User Navigation
**Goal:** Give users a quick link to an external contract record.
```text
HYPERLINK(
"https://contracts.example.org/" & External_Contract_Id__c,
"Open Contract",
"_blank"
)
```
**Rule:** Keep this as convenience-only. The external key still belongs in a normal field.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |