Custom Formula
Build powerful expressions combining multiple functions to transform your data in a single workflow step.
What Does This Action Do?
The Custom Formula action lets you write an expression (like a spreadsheet formula) that combines multiple functions and HubSpot property values. Instead of chaining several Format Data steps together, you can do it all in one formula.
For example, instead of three separate steps to trim a name, capitalize it, and concatenate it with a greeting, you can write: CONCAT("Hello, ", CAPITALIZE(TRIM([[input1]])))
When Should You Use It?
- •Complex transformations -- When you need to combine multiple operations (trim + capitalize + concatenate) in one step.
- •Conditional formatting -- Use IF() to return different values based on property values, like assigning lead tiers.
- •Multi-step calculations -- Chain math functions together, like calculating a discounted price with tax.
- •Date math with formatting -- Calculate a future date and format it for an email, all in one step.
How It Works
Add the action to your workflow
Search for "HubHacks: Custom Formula" under Custom Actions in your workflow editor.
Map HubSpot properties to inputs
Use the property picker to map properties to Input 1, Input 2, Input 3. These become available in your formula.
Write your formula
Type your formula using functions and property references. The result is returned as the output.
CONCAT(CAPITALIZE([[input1]]), " ", UPPER([[input2]]))
Use the result
The formula result is available as Output 1 in the next workflow step.
Property References
There are two ways to reference HubSpot property values in your formula:
Input Picker References
[[input1]], [[input2]], [[input3]]Use the property picker to map a HubSpot property to an input. Then reference it with double brackets. This is the recommended approach because it works with any property type.
Direct Property References
{{firstname}}, {{dealname}}Reference a HubSpot property directly by its internal name using double curly braces. Useful when you know the exact property name.
Available Functions
Here is a summary of all available functions. For complete details, syntax, and advanced examples, see the full Formula Reference.
| Function | Description | Example |
|---|---|---|
| UPPER(text) | Convert to uppercase | UPPER("hello") → "HELLO" |
| LOWER(text) | Convert to lowercase | LOWER("HELLO") → "hello" |
| CAPITALIZE(text) | Capitalize each word | CAPITALIZE("john smith") → "John Smith" |
| TRIM(text) | Remove leading/trailing spaces | TRIM(" hi ") → "hi" |
| LEFT(text, n) | Get first n characters | LEFT("Hello", 3) → "Hel" |
| RIGHT(text, n) | Get last n characters | RIGHT("Hello", 3) → "llo" |
| MID(text, start, length) | Extract substring | MID("Hello World", 6, 5) → "World" |
| LEN(text) | Count characters | LEN("Hello") → 5 |
| CONCAT(a, b, ...) | Join multiple values | CONCAT("Hi", " ", "there") → "Hi there" |
| REPLACE(text, find, replacement) | Find and replace text | REPLACE("hello", "l", "r") → "herro" |
| CONTAINS(text, search) | Check if text contains a value | CONTAINS("hello", "ell") → true |
| SPLIT(text, separator, index) | Split and get part | SPLIT("a@b.com", "@", 1) → "b.com" |
| Function | Description | Example |
|---|---|---|
| ADD(a, b) | Add two numbers | ADD(10, 5) → 15 |
| SUBTRACT(a, b) | Subtract b from a | SUBTRACT(10, 3) → 7 |
| MULTIPLY(a, b) | Multiply two numbers | MULTIPLY(5, 4) → 20 |
| DIVIDE(a, b) | Divide a by b | DIVIDE(20, 4) → 5 |
| MOD(a, b) | Remainder after division | MOD(10, 3) → 1 |
| ROUND(number, decimals) | Round to n decimal places | ROUND(3.456, 2) → 3.46 |
| FLOOR(number) | Round down | FLOOR(3.9) → 3 |
| CEIL(number) | Round up | CEIL(3.1) → 4 |
| ABS(number) | Absolute value | ABS(-42) → 42 |
| MIN(a, b) | Smaller of two values | MIN(5, 3) → 3 |
| MAX(a, b) | Larger of two values | MAX(5, 3) → 5 |
| Function | Description | Example |
|---|---|---|
| NOW() | Current date and time | NOW() → "2024-03-15T10:30:00Z" |
| TODAY() | Current date | TODAY() → "2024-03-15" |
| DATE_ADD(date, days) | Add days to a date | DATE_ADD("2024-01-01", 30) → "2024-01-31" |
| DATE_SUB(date, days) | Subtract days from a date | DATE_SUB("2024-01-31", 30) → "2024-01-01" |
| DATE_DIFF(date1, date2) | Days between two dates | DATE_DIFF("2024-01-01", "2024-02-01") → 31 |
| DATE_FORMAT(date, format) | Format a date string | DATE_FORMAT("2024-01-15", "MM/DD/YYYY") → "01/15/2024" |
| YEAR(date) | Extract the year | YEAR("2024-01-15") → 2024 |
| MONTH(date) | Extract the month | MONTH("2024-01-15") → 1 |
| DAY(date) | Extract the day | DAY("2024-01-15") → 15 |
| Function | Description | Example |
|---|---|---|
| IF(condition, then, else) | Conditional logic | IF(score > 80, "Hot", "Cold") → "Hot" |
| AND(a, b) | True if both are true | AND(true, false) → false |
| OR(a, b) | True if either is true | OR(true, false) → true |
| NOT(value) | Negate a boolean | NOT(true) → false |
| DEFAULT(value, fallback) | Use fallback if value is empty | DEFAULT("", "N/A") → "N/A" |
| EQUALS(a, b) | Check if values are equal | EQUALS("yes", "yes") → true |
| Function | Description | Example |
|---|---|---|
| NUMBER(text) | Convert text to number | NUMBER("42.5") → 42.5 |
| TEXT(number) | Convert number to text | TEXT(42) → "42" |
| CURRENCY(number) | Format as currency | CURRENCY(1500) → "$1,500.00" |
| PERCENT(number) | Format as percentage | PERCENT(0.85) → "85%" |
Complete docs for every function with detailed syntax, edge cases, and advanced examples.
Real-World Examples
Full Name Formatting
Clean up and combine first and last name, handling messy data with extra spaces or inconsistent casing.
" john ")"SMITH")CONCAT(CAPITALIZE(TRIM([[input1]])), " ", CAPITALIZE(TRIM([[input2]])))
"John Smith"Lead Scoring Formula
Assign a lead tier based on company size. Large companies get "Enterprise", medium get "Mid-Market", small get "SMB".
"500")IF(NUMBER([[input1]]) > 1000, "Enterprise", IF(NUMBER([[input1]]) > 100, "Mid-Market", "SMB"))
"Mid-Market"Trial Expiration Date
Calculate when a 14-day trial ends and format it for an email.
"2024-03-01")DATE_FORMAT(DATE_ADD([[input1]], 14), "MMMM D, YYYY")
"March 15, 2024"Personalized Email Greeting
Build a greeting that uses the contact's first name if available, or falls back to a generic greeting.
"" -- empty)CONCAT("Hi ", DEFAULT(CAPITALIZE([[input1]]), "there"), "! Here's your weekly update.")"Hi there! Here's your weekly update."Tips and Best Practices
DEFAULT([[input1]], "0")ADD(NUMBER([[input1]]), 10)