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.
Format Data vs Custom Formula: Use Format Data for simple, single operations (like "make this uppercase"). Use Custom Formula when you need to nest or combine multiple operations in one expression.

How It Works

1

Add the action to your workflow

Search for "HubHacks: Custom Formula" under Custom Actions in your workflow editor.

2

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.

3

Write your formula

Type your formula using functions and property references. The result is returned as the output.

CONCAT(CAPITALIZE([[input1]]), " ", UPPER([[input2]]))
4

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.

Text Functions
FunctionDescriptionExample
UPPER(text)Convert to uppercaseUPPER("hello") → "HELLO"
LOWER(text)Convert to lowercaseLOWER("HELLO") → "hello"
CAPITALIZE(text)Capitalize each wordCAPITALIZE("john smith") → "John Smith"
TRIM(text)Remove leading/trailing spacesTRIM(" hi ") → "hi"
LEFT(text, n)Get first n charactersLEFT("Hello", 3) → "Hel"
RIGHT(text, n)Get last n charactersRIGHT("Hello", 3) → "llo"
MID(text, start, length)Extract substringMID("Hello World", 6, 5) → "World"
LEN(text)Count charactersLEN("Hello") → 5
CONCAT(a, b, ...)Join multiple valuesCONCAT("Hi", " ", "there") → "Hi there"
REPLACE(text, find, replacement)Find and replace textREPLACE("hello", "l", "r") → "herro"
CONTAINS(text, search)Check if text contains a valueCONTAINS("hello", "ell") → true
SPLIT(text, separator, index)Split and get partSPLIT("a@b.com", "@", 1) → "b.com"
Math Functions
FunctionDescriptionExample
ADD(a, b)Add two numbersADD(10, 5) → 15
SUBTRACT(a, b)Subtract b from aSUBTRACT(10, 3) → 7
MULTIPLY(a, b)Multiply two numbersMULTIPLY(5, 4) → 20
DIVIDE(a, b)Divide a by bDIVIDE(20, 4) → 5
MOD(a, b)Remainder after divisionMOD(10, 3) → 1
ROUND(number, decimals)Round to n decimal placesROUND(3.456, 2) → 3.46
FLOOR(number)Round downFLOOR(3.9) → 3
CEIL(number)Round upCEIL(3.1) → 4
ABS(number)Absolute valueABS(-42) → 42
MIN(a, b)Smaller of two valuesMIN(5, 3) → 3
MAX(a, b)Larger of two valuesMAX(5, 3) → 5
Date Functions
FunctionDescriptionExample
NOW()Current date and timeNOW() → "2024-03-15T10:30:00Z"
TODAY()Current dateTODAY() → "2024-03-15"
DATE_ADD(date, days)Add days to a dateDATE_ADD("2024-01-01", 30) → "2024-01-31"
DATE_SUB(date, days)Subtract days from a dateDATE_SUB("2024-01-31", 30) → "2024-01-01"
DATE_DIFF(date1, date2)Days between two datesDATE_DIFF("2024-01-01", "2024-02-01") → 31
DATE_FORMAT(date, format)Format a date stringDATE_FORMAT("2024-01-15", "MM/DD/YYYY") → "01/15/2024"
YEAR(date)Extract the yearYEAR("2024-01-15") → 2024
MONTH(date)Extract the monthMONTH("2024-01-15") → 1
DAY(date)Extract the dayDAY("2024-01-15") → 15
Logic Functions
FunctionDescriptionExample
IF(condition, then, else)Conditional logicIF(score > 80, "Hot", "Cold") → "Hot"
AND(a, b)True if both are trueAND(true, false) → false
OR(a, b)True if either is trueOR(true, false) → true
NOT(value)Negate a booleanNOT(true) → false
DEFAULT(value, fallback)Use fallback if value is emptyDEFAULT("", "N/A") → "N/A"
EQUALS(a, b)Check if values are equalEQUALS("yes", "yes") → true
Format Functions
FunctionDescriptionExample
NUMBER(text)Convert text to numberNUMBER("42.5") → 42.5
TEXT(number)Convert number to textTEXT(42) → "42"
CURRENCY(number)Format as currencyCURRENCY(1500) → "$1,500.00"
PERCENT(number)Format as percentagePERCENT(0.85) → "85%"
View the Full Formula Reference →

Complete docs for every function with detailed syntax, edge cases, and advanced examples.

Real-World Examples

Example 1

Full Name Formatting

Clean up and combine first and last name, handling messy data with extra spaces or inconsistent casing.

Input 1: First Name (" john ")
Input 2: Last Name ("SMITH")
CONCAT(CAPITALIZE(TRIM([[input1]])), " ", CAPITALIZE(TRIM([[input2]])))
Result: "John Smith"
Example 2

Lead Scoring Formula

Assign a lead tier based on company size. Large companies get "Enterprise", medium get "Mid-Market", small get "SMB".

Input 1: Number of Employees ("500")
IF(NUMBER([[input1]]) > 1000, "Enterprise", IF(NUMBER([[input1]]) > 100, "Mid-Market", "SMB"))
Result: "Mid-Market"
Example 3

Trial Expiration Date

Calculate when a 14-day trial ends and format it for an email.

Input 1: Create Date ("2024-03-01")
DATE_FORMAT(DATE_ADD([[input1]], 14), "MMMM D, YYYY")
Result: "March 15, 2024"
Example 4

Personalized Email Greeting

Build a greeting that uses the contact's first name if available, or falls back to a generic greeting.

Input 1: First Name ("" -- empty)
CONCAT("Hi ", DEFAULT(CAPITALIZE([[input1]]), "there"), "! Here's your weekly update.")
Result: "Hi there! Here's your weekly update."

Tips and Best Practices

✓
Start simple, then nest. Write the inner function first, test it, then wrap it in the next function. This makes debugging easier.
✓
Use DEFAULT() for optional properties. If a property might be empty, wrap it in DEFAULT() to avoid errors: DEFAULT([[input1]], "0")
✓
Convert types when mixing. Use NUMBER() when doing math on text inputs: ADD(NUMBER([[input1]]), 10)
✓
Use the Formula Reference. The full reference has detailed syntax, edge cases, and advanced examples for every function.
✓
Prefer [[input]] over {{property}}. The input picker approach is more reliable because it handles all property types correctly.
✓
Keep formulas readable. For very complex logic, consider using the Run Code action instead, which gives you full JavaScript.

Related Documentation