Skip to content

PranavNagrecha/AwesomeSalesforceSkills / skills/admin/formula-fields

formula-fields

Verified

Use 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.

references/well-architected.md

View on GitHub
# Well-Architected Mapping: Formula Fields

## Pillars Addressed

### Performance

Formula fields are easy to create and easy to overuse.

- Careful cross-object usage prevents avoidable reporting and page-load pain.
- Simple formulas reduce admin tendency to offload all logic into runtime recalculation.

### Reliability

Good formulas return the right value for real-world edge cases.

- Explicit blank handling reduces misleading outputs.
- Correct tool choice prevents formula fields from being misused as historical snapshots.

### Operational Excellence

Readable formulas are maintainable formulas.

- Documentation and simpler expressions reduce admin handoff risk.
- Review discipline prevents nested formula debt from spreading across the org.

## Pillars Not Addressed

- **Security** - formula design does not directly govern record access.
- **User Experience** - formulas can help UX, but this skill is about correctness and maintainability first.

## Official Sources Used

- Salesforce Well-Architected Overview — performance and maintainability framing for formula usage
- Metadata API Developer Guide, *CustomField* → Fields (v62 PDF, https://resources.docs.salesforce.com/262/latest/en-us/sfdc/pdf/api_meta.pdf; api_meta.txt:43422-43426) — the `formula` and `formulaTreatBlanksAs` elements and the `BlankAsBlank` / `BlankAsZero` enum (`references/metadata-examples.md`, gotchas "One Switch For The Whole Formula")
- Metadata API Developer Guide, *CustomField* → Declarative Metadata File Suffix, Wildcard Support, and Sample Definition (api_meta.txt:43226, 43248-43252, 43934-43946, 43983-43984) — `Object.Field__c` member syntax, no `*` wildcard, FLS pulled into profiles on retrieve, and the `<fields>`-inside-`<CustomObject>` shape (`references/metadata-examples.md` "Where the file lives", "package.xml")
- Metadata API Developer Guide, *CustomField* → `precision`, `scale`, `externalId` (api_meta.txt:43401-43404, 43563-43565, 43610-43612) — numeric return-type elements and why `externalId` / `unique` are inert on a formula (`references/metadata-examples.md` "How to read it")
- Metadata API Developer Guide — `<formula>` XML escaping in the guide's own samples: `Name &amp; &quot;Updated&quot;` (api_meta.txt:140599) and `&apos;` in `errorConditionFormula` (api_meta.txt:45439-45440) (gotchas "A `<` Or `&` In The Formula Breaks The Deploy")
- Metadata API Developer Guide, *ArticleType CustomField* → `type` (api_meta.txt:22161-22178) — the one place `Formula` is a `FieldType` value, which is why a regular formula field's `<type>` is its return type instead
- Metadata API Developer Guide, *FlowSettings* → `doesFormulaGenerateHtmlOutput` (api_meta.txt:116861-116863) — `BR()`, `IMAGE()`, `HYPERLINK()` named as the HTML-generating family, evaluated by the Flow engine rather than the formula-field engine (`references/metadata-examples.md`, IMAGE example)
- Object Reference, *Calculated Field Type* (v62 PDF, https://resources.docs.salesforce.com/262/latest/en-us/sfdc/pdf/object_reference.pdf; object_reference.txt:2207-2211) — "Calculated fields are read-only fields in the API"; "You can filter on these fields in SOQL, but you don't replicate these fields"; "The length of text calculated fields is 3,900 characters or less — anything longer is truncated" (gotchas "Read-Only In The API", "Do Not Replicate", "Truncated At 3,900 Characters")
- Tips for Reducing Formula Size — Reducing the Length of Your Formula: https://developer.salesforce.com/docs/atlas.en-us.salesforce_formula_size_tipsheet.meta/salesforce_formula_size_tipsheet/reducing_formula_length.htm — "Maximum number of characters: 3,900 characters"; "Maximum formula size when saved: 4,000 bytes"
- Tips for Reducing Formula Size — Reducing Your Formula's Compile Size: https://developer.salesforce.com/docs/atlas.en-us.salesforce_formula_size_tipsheet.meta/salesforce_formula_size_tipsheet/reducing_formula_compile_size.htm — "Maximum formula size (in bytes) when compiled: 5,000 bytes"; compile size reflects the generated query, so shortening the formula text does not reduce it
- Salesforce Help — Formula Field Limits and Restrictions: https://help.salesforce.com/s/articleView?id=platform.formula_field_limits.htm&type=5 — all formula limits apply uniformly to every object; there is no object-dependent variant
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 119kUpdated Claude CodeCodexVerifiedInstall
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: 118kUpdated Claude CodeCodexVerifiedInstall