Skip to content
Workflows

Custom Formula Functions

Last updated: July 28, 2022

Applies to:

Operations Hub Professional, Enterprise

If you're using a custom formula to format your data in a workflow, you can use functions with property values from the enrolled record or outputs from previous actions to create complex formulas.  

Review the different functions below to determine which to use: 

Function Description Example
abs Retrieve the absolute value of a number. You can use this function to make sure that a number is positive.
  • example formula: abs([number or number property])
    • example: abs(-10) 
    • example output: 10
add Adds a numeric value to another numeric value. This function is the same as the + operator. Use with the following: 
  • number: the initial numeric value for the operation.
  • number to add: the number to be added to the initial numeric value. 
  • example formula: add(number, number to add)
    • example: add(5, 10)
    • example output: 15

Alternatively, you can also use:

  • example formula: number + number to add
    • example: 5+10
    • example output: 15
concat Combine multiple string values. This function is only available when the Format data action is used in Custom mode
  • example formula: concat([string 1], [string 2]) 
    • example: concat([company name], [MonthYear])
    • example output: HubSpot June 2006
capitalize Capitalize the first letter of a string value. The first character will be uppercase, while all others letters will be lowercased. Other words in the input won't have their first letter uppercased
  • example formula: capitalize([string])
    • example: capitalize([firstname])
    • example output: Henry
cut Cut a character or multiple characters to removes a string from a value. This function can be used to match and cut out a specific part of a string. The parameter specifies the part of the string that should be removed. Use with the following: 
  • source: the source string to remove characters from. 
  • characters_to_cut: the specific characters to remove. This format is case sensitive. 
  • formula: cut(source, characters to cut)
    • example: cut([phone], "-")
    • example output: 80081234567 


datetimeformat Change the date format to convert a timestamp into human-friendly text. Use the format parameter to choose how the resulting text will appear. Use with the following:
  • datetime: the date/time object to format.
  • format: the format for the date/time object. This parameter uses the formatting tokens from the HubL datetimeformat filter
  • formula: datetimeformat(datetime, format, timezone)
    • example: datetimeformat([closedate], %B %e %Y %l %p", "America/Los_Angeles")
    • example output: October 1 2020 9 AM
divide Divide a number. This function is an alternative to the / operator. Use with the following: 
  • number: the number to divide. 
  • divisor: the number to divide by for the divide operation. 
  • formula: divide(number, divisor)
    • example: divide (8, 4)
    • example output: 2

Alternatively, you can also use: 

  • formula: number/divisor
    • example: 8/4
    • example output: 2
divisible Test if a number is evenly divisible. When there is no remainder, this function will evaluate to true. When there is a remainder, this function will evaluate to false. Use with the following: 
  • number: the number to divide. 
  • divisor: the number to divide by for the divide operation. 
  • formula: divisible(number, divisor)
    • example: divisible (5,2)
    • example output: false
join Combine two or more strings into one result string, using a separator between each value. This function is only available when the Format data action is used in Custom mode

Use with the following: 
  • delimiter: a separator string to be inserted between each item.
  • items: any number of strings to combine. 
  • formula: join(delimiter, items)
    • example: join("-", "A", "B", "C")
    • example output: A-B-C
lower Convert all characters in a string to all lowercase letters.
  • formula: lower([string])
    • example: lower(["HELLO WORLD"])
    • example output: hello world
minus_time Subtracts an amount of time from a date/time object. Use with the following: 
  • datetime: the date/time object to add time to.
  • diff: the amount of time to add. 
  • timeunit: the unit of time to be added. The following can be used: 
    • seconds
    • minutes
    • hours
    • half_days
    • days
    • weeks
    • months
    • years
  • formula: minus_time(datetime, diff, timeunit)
    • example: minus_time([closedate], 2, "days")
    • example output: 04/11/2020
multiplier Multiplies a value by a number. This function is an alternative to the * operator. Use with the following: 
  • number: the number to multiply.
  • multiplier: the number to multiply by. 
  • formula: multipler(number, multipler)
    • example: multiplier(5, 3) 
    • example output: 15

Alternatively, you can also use:

  • formula: number*multipler
    • example: 5*3 
    • example output: 15
plus_time Add an amount of time to a date/time object. Use with the following: 
  • datetime: the date/time object to add time to.
  • diff: the amount of time to add. 
  • timeunit: the unit of time to be added. 
  • formula: plus_time(datetime, diff, timeunit)
    • example: plus_time([closedate], 2, "days")
    • example output: 06/11/2020


randomNumber Generate a random number within a range.

With this function, the numbers generated are completely random and may repeat. For example, if you used a range of one to three and enrolled three contacts, you may not get three unique numbers.  

Both minimum and maximum numbers are included in the range. You can also use 0 and negative numbers when setting your range. 
  • formula: randomNumber(minimum, maximum)
    • example: randomNumber(1, 3)
    • example output: 1 or 2
replace Replace all instances of a substring with a different string. Use with the following: 
  • string: the string to search for and replace. 
  • old: the substring that should be replaced. 
  • new: the replacement string. 
  • count: the number of instances of the substring to replace. If not provided, all substrings will be replaced
  • formula: replace(string, old, new, count)
    • example: replace( "Hello world!", "Hello", "Hi", 1)
    • example output: Hi world!
root Calculate the square root of a number. Optionally, specify the Nth root to calculate. Use with the following:
  • number: the number to take the root of.Calculate the square root of a number. Optionally, specify the Nth root to calculate 
  • nthRoot: the nth root to be calculated. If not specified, the square root will be taken. 
  • formula: root(number, nthRoot)
    • example: root(625, 4)
    • example output: 5
round Round a number to a specified decimal. Use with the following:
  • precision: the decimal to round to.  
  • rounding method: round up or down to the nearest whole number.  The following rounding methods can be used: 
    • common
    • ceil
    • floor
  • formula: round(number, precision, rounding method)
    • example: round(52.5, 0, 'floor')
    • example output: 52
striptags Strip SGML/XML tags and replace adjacent whitespace by one space. This filter can be used to remove any HTML tags from a variable.
  • formula: striptags([string])
    • example: striptags(<div><p>Potato</p></div>)
    • example output: Potato
title Change text to title casing. Each word in the resulting string will start with uppercase letters, while all remaining characters are lowercase.
  • formula: title([string])
    • example: title("cheddar CHEESE")
    • example output: Cheddar Cheese
trim Remove leading and trailing whitespace from a string.
  • formula: trim([string])
    • example: trim(" peach ")
    • example output: peach
unixtimestamp Convert a date/time object into a Unix timestamp.
  • formula: unixtimestamp([dateteime])
    • example: unixtimesstamp([closedate])
    • example output: 1652863824
upper Change all characters to uppercase.
  • formula: upper([string])
    • example: upper("teatime")
    • example output: TEATIME
urlencode Escape and URL encode a string using UTF-8 formatting.
  • formula: urlencode([string])
    • example: urlencode("hi there")
    • example output: hi%20there
Was this article helpful?
This form is used for documentation feedback only. Learn how to get help with HubSpot.