Create Formula Field
sf_create_formula_fieldCreate a formula field on any Salesforce object with full formula language support, including all return types, cross-object references, and complex multi-line formulas.
Instructions
Creates a formula field on any Salesforce object. Supports all return types (Text, Number, Currency, Date, DateTime, Checkbox, Percent) and the full Salesforce formula language: IF/AND/OR/NOT, BLANKVALUE, TEXT, VALUE, DATE, DATEVALUE, TODAY, NOW, date functions (MONTH/YEAR/DAY), math (FLOOR/CEILING/MOD), string functions (LEN/LEFT/RIGHT/MID/TRIM/UPPER/LOWER/CONTAINS/BEGINS), record type and picklist functions (ISPICKVAL, ISNULL, ISBLANK), cross-object field references (e.g. Account.Owner.Name), and VLOOKUP. Complex multi-line formulas are fully supported.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label | Yes | Field label | |
| scale | No | Decimal places for Number/Currency/Percent return types | |
| formula | Yes | Salesforce formula expression. Supports all Salesforce formula functions: IF, AND, OR, NOT, BLANKVALUE, TEXT, VALUE, DATE, DATEVALUE, TODAY, NOW, MONTH, YEAR, DAY, FLOOR, CEILING, MOD, LEN, LEFT, RIGHT, MID, TRIM, UPPER, LOWER, CONTAINS, BEGINS, ISPICKVAL, ISNULL, ISBLANK, cross-object fields (e.g. Account.Owner.Name), etc. | |
| fieldName | Yes | Field name without __c suffix | |
| precision | No | Total number of digits for Number/Currency/Percent return types (default 18) | |
| returnType | Yes | Formula return type | |
| description | No | Field description | |
| objectApiName | Yes | Object API name, e.g. 'Opportunity' | |
| formulaTreatBlanksAs | No | How to treat blank fields in the formula. Defaults to BlankAsZero for numeric types, BlankAsLogicalFalse for Checkbox. |