nadolskimm-max/sf-skills/sf-formula

Claude Code and agent skill by nadolskimm-max/sf-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Creates Salesforce formula fields, validation rules, and formula-based automation. Use when writing formula field expressions, building validation rules, troubleshooting formula compilation errors, or optimizing formula performance (compiled size limits). Do NOT use for SOQL queries (use sf-soql) or Flow formulas (use sf-flow).

Install

npx vskill@latest install nadolskimm-max/sf-skills/sf-formula

SKILL.md

Salesforce Formulas & Validation Rules

Core Responsibilities

  1. Create formula fields (text, number, checkbox, date)
  2. Build validation rules with complex conditions
  3. Troubleshoot formula compilation errors and size limits
  4. Handle null values and cross-object references
  5. Optimize formula performance

Formula Field Types

Return TypeUse CaseExample
TextConcatenation, formattingFull Name, formatted address
NumberCalculationsDiscount amount, days open
CurrencyFinancial calculationsWeighted revenue
PercentRatiosWin rate, completion %
CheckboxBoolean logicIs High Value?, Is Overdue?
DateDate calculationsDue Date, Next Review Date
DateTimeTimestamp calculationsSLA deadline

Common Formula Patterns

Null-Safe Field Access
IF(ISBLANK(Amount), 0, Amount * Discount_Percent__c / 100)
Cross-Object Reference
Account.Owner.Manager.Email
Text Concatenation
IF(ISBLANK(MailingStreet), '',
MailingStreet & BR() &
MailingCity & ', ' & MailingState & ' ' & MailingPostalCode &
BR() & MailingCountry
)
Date Calculations
/* Days until close */
CLOSE_DATE - TODAY()
/* Business days between two dates (approximate) */
(CLOSE_DATE - CreatedDate) - (FLOOR((CLOSE_DATE - CreatedDate) / 7) * 2)
/* Next business day */
CASE(
MOD(TODAY() - DATE(1900, 1, 7), 7),
5, TODAY() + 3,
6, TODAY() + 2,
TODAY() + 1
)
Conditional Logic
CASE(StageName,
'Prospecting', 10,
'Qualification', 25,
'Proposal', 50,
'Negotiation', 75,
'Closed Won', 100,
0
)
Image Formula
IMAGE(
CASE(Priority,
'High', '/img/samples/flag_red.gif',
'Medium', '/img/samples/flag_yellow.gif',
'/img/samples/flag_green.gif'
),
Priority, 16, 16
)

Validation Rules

Required Field Conditionally
xml
<?xml version="1.0" encoding="UTF-8"?>
<ValidationRule xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Require_Close_Date_When_Closed</fullName>
<active>true</active>
<errorConditionFormula>AND(
ISPICKVAL(StageName, 'Closed Won'),
ISBLANK(CloseDate)
)</errorConditionFormula>
<errorDisplayField>CloseDate</errorDisplayField>
<errorMessage>Close Date is required when Stage is Closed Won.</errorMessage>
</ValidationRule>
Prevent Backdating
CloseDate < TODAY() && ISCHANGED(CloseDate)
Email Format Validation
AND(
NOT(ISBLANK(Email)),
NOT(REGEX(Email, '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$'))
)
Cross-Object Validation
AND(
ISPICKVAL(Status__c, 'Active'),
Account.IsDeleted
)

REGEX Patterns

PatternMatches
^[0-9]{5}(-[0-9]{4})?$US ZIP code (12345 or 12345-6789)
^\\+?[1-9]\\d{1,14}$E.164 phone number
^[A-Z]{2}[0-9]{2}[A-Z0-9]{4}[0-9]{7}([A-Z0-9]?){0,16}$IBAN
^[0-9]{3}-[0-9]{2}-[0-9]{4}$US SSN format

Compiled Size Limits

LimitMaximum
Formula field compiled size5,000 characters
Validation rule formula size5,000 characters
Cross-object spansMax 10 relationships
SOQL in formulasNot allowed
Size Reduction Tips
  • Replace IF(condition, true, false) with just condition for checkboxes
  • Use CASE instead of nested IF (smaller compiled size)
  • Move complex logic to Apex/Flow if approaching limits
  • Avoid deep cross-object references (each span adds ~200 chars)

Anti-Patterns

Anti-PatternFix
No null handlingWrap in IF(ISBLANK(...)) or BLANKVALUE()
Nested IF > 5 levelsUse CASE statement instead
Hardcoded picklist valuesUse ISPICKVAL() for type safety
Formula field referencing formula fieldBeware of compiled size cascade
Validation rule with no error message contextPoint to specific field with errorDisplayField

Cross-Skill References

  • For formula fields in metadata: see sf-metadata
  • For Flow formula resources: see sf-flow
  • For validation rule deployment: see sf-deploy

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Refreshed 20 Mar 2026, 8 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/nadolskimm-max/sf-skills/sf-formula/badge)](https://verified-skill.com/skills/nadolskimm-max/sf-skills/sf-formula)

Something wrong with this skill or its page? Tell us.