documentation logo
All you’ll ever need to know about Declarative Webhooks and how to get started.

Pages

Using Formulas

Where are formulas used

Currently, you can use formulas to:

  • generate JSON nodes when you are building the Request Body of a Callout Template or when you are building the Response Body of an Inbound Call Template
  • map the values from the response body of a callout or from the request body of an inbound call

Using formulas to generate JSON nodes or form-encoded fields

In the JSON Builder, when you define the request body of a callout template or the response body of an inbound call template, you have the option to use formulas. Just make sure to select Formula in the Value Source input and click on the Edit icon on the right to open the formula editor.

When using formula editor in this context, you can use: fields from the main object or related objects, operators and functions.

See more details about each option in the Formula Builder section below.

Using formulas to map response body or request body values into Salesforce fields

When you are defining the mapping in a Response Action (for Callout Templates) or Inbound Call Action (for Inbound Call Templates), you have the option to use formulas to transform the received values before saving them into fields.

Make sure to select Formula as the Type in the mapping fields section and click on the blue edit button on the right.

When using the formula editor in this context, you can use: nodes from the response / request body, received URL parameters (for inbound calls only), received header values (for inbound calls only), operators and functions.

See more details about each option in the Formula Builder section below.

 

Formula Builder

Fields

When you define the request body of a callout template or the response body of an inbound call template, you can use any field from the current object (or related objects) in your formula. The current object is usually the selected Main Object, but if you are inside a List node with a selected related list, the current object will be the object in that related list.

Click on “Insert Body Node” input and search for the name of the field or relationship, then click on “Done” to insert it into the formula field.

Request / Response body nodes

When you are using the formula editor to map fields from the received response body in a Response Action, you can use the “Insert Body Node” input to insert a node from the body in the formula.

When you are using the formula editor to map fields from the received request body in an Inbound Call Action, you can use the “Insert Body Node” button to insert a node from the body in the formula.

Alternatively, you can manually type a JSON body reference in this format: NODE:”path.to.node”. For example, NODE:”tasks.description”.

URL parameters

When you are using the formula editor in an Inbound Call Action, you can use the “Insert URL Parameter” input and button to insert an URL parameter into the formula.

Alternatively, you can manually type a URL parameter reference in this format: PARAM:”name_of_parameter”. For example: PARAM:”accountId”.

Inbound call Headers

When you are using the formula editor in an Inbound Call Action, you can use the “Insert Header” button to insert a received header into the formula.

Alternatively, you can manually type a header reference in this format: HEADER:”name_of_header”. For example: PARAM:”Content-Type”.

Operators

There are currently 14 operators supported by the Formula Builder, each of them explained below:

  1. ^ (Exponentiation): Use this to calculate the power of two numbers. Returned value is a number. Example: 4 ^ 3 will return 64.
  2. * (Multiply): Use this to calculate the multiplication of two numbers. Returned value is a number. Example: 4 * 3 will return 12.
  3. / (Divide): Use this to calculate the division between two numbers. Returned value is a number. Example: 6 / 3 will return 2.
  4. + (Add): Use this to calculate the sum of two numbers. Returned value is a number. Example: 6 + 2 will return 8.
  5. – (Substract): Use this to calculate the difference between 2 numbers. Returned value is a number. Example: 6 – 2 will return 4.
  6. & (Concatenate): Use this to concatenate 2 text values. If the values are not text, they are converted. Returned value is a text. Example: “Hello ” & “world” will return “Hello world”.
  7. = (Equal): Use this to compare 2 values and return true if hey are equal. The values can be any type. Returned value is a boolean (true/false). Example: 2 = 2 will return true.
  8. <> (Not Equal): Use this to compare 2 values and return true if they are different. The values can be any type. Returned value is a boolean (true/false). Example: 2 <> 2 will return false.
  9. < (Less Than): Use this to compare 2 values and return true if the first one is less than the second one. The values can be any type. Returned value is a boolean (true/false). Example: 2 < 2 will return false.
  10. > (Greater Than): Use this to compare 2 values and return true if the first one is greater than the second one. The values can be any type. Returned value is a boolean (true/false). Example: 2 > 2 will return false.
  11. <= (Less Than or Equal): Use this to compare 2 values and return true if the first one is less or equal than the second one. The values can be any type. Returned value is a boolean (true/false). Example: 2 <= 2 will return true.
  12. >= (Greater Than or Equal): Use this to compare 2 values and return true if the first one is greater or equal than the second one. The values can be any type. Returned value is a boolean (true/false). Example: 2 => 2 will return true.
  13. && (And): Use this as an AND operator between two boolean (true/false) values. Returned value is a boolean(true/false). Example: true && false will return false.
  14. || (Or): Use this as an OR operator between two boolean (true/false) values. Returned value is a boolean(true/false). Example: true || false will return true.

Functions

Currently, there are 35 functions that can be used in the Formula Builder:

  1. ADDDAYS: Use this function to add a number of days to a date or date/time. The function receives two variables: first is the date or date/time value and the second one is the number of days (which can also be negative). Usage: ADDDAYS(date/time, days)
  2. ADDHOURS: Use this function to add a number of hours to a date/time variable. The function receives two variables: first is the date/time value and the second one is the number of hours (which can also be negative). Usage: ADDHOURS(date/time, hours)
  3. ADDMINUTES: Use this function to add a number of minutes to a date/time variable. The function receives two variables: first is the date/time value and the second one is the number of minutes (which can also be negative). Usage: ADDMINUTES(date/time, minutes)
  4. ADDMONTHS: Use this function to add a number of months to a date or date/time. The function receives two variables: first is the date or date/time value and the second one is the number of months (which can also be negative). Usage: ADDMONTHS(date/time, months)
  5. ADDYEARS: Use this function to add a number of years to a date or date/time. The function receives two variables: first is the date or date/time value and the second one is the number of years (which can also be negative). Usage: ADDYEARS(date/time, years)
  6. AND: Use this function as an AND operator between a number of boolean(true/false) values. The function can receive two or more boolean(true/false) values and will return a boolean(true/false) Usage: AND(value1, value2, …)
  7. CASE: Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn’t equal to any values, it returns the else_result. Usage: CASE(expression, value1, result1, value2, result2,…, else_result)
  8. ESCAPEHTML: This function escapes HTML characters from the received value. For example, if the input parameter is “<br>”, the returned value is “&lt;br&gt;”. (Equivalent to Apex: String.escapeHtml4()) Usage: ESCAPEHTML(textvalue)
  9. ESCAPEJAVA: This function returns a String whose characters are escaped using Java String rules. Characters escaped include quotes and control characters, such as tab, backslash, and carriage return characters.. (Equivalent to Apex: String.escapeJava()) Usage: ESCAPEJAVA(textvalue)
  10. FORMAT: This function receives a date or date/time value and a text containing the format. It returns the formatted date in the current user timezone, as a text. Usage: FORMAT(date/time, format)
  11. FORMATGMT: This function receives a date or date/time value and a text containing the format. It returns the formatted date in GMT, as a text. Usage: FORMATGMT(date/time, format)
  12. IF: Determines if an expression is true or false. Returns a given value if true and another value if false. Usage: IF(logical_test, value_if_true, value_if_false) 
  13. INDEXOF: Returns the position of the first occurrence of a text in another text. Usage: INDEXOF(text_to_search_into, text_to_search_for)
  14. ISBLANK: Determines if an expression has a value and returns true if it doesn’t. If it contains a value, this function returns false. Usage: ISBLANK(expression) 
  15. LASTINDEXOF: Returns the position of the last occurrence of a text in another text. Usage: LASTINDEXOF(text_to_search_into, text_to_search_for)
  16. LEFT: Returns the specified number of characters from the beginning of a text string. Usage: LEFT(text, num_chars)
  17. LEFTBYTES: Cuts the end of a text to limit the byte size to a specified size. Usage: LEFTBYTES(text, byte_size)
  18. LEN: Returns the number of characters in a text. Usage: LEN(text)
  19. LENBYTES: Returns the number of bytes in a text string. Usage: LENBYTES(text)
  20. MAX: Returns the highest value from a list of values. Usage: MAX(value1, value2, …) 
  21. MID: Returns the specified number of characters from the middle of a text string given the starting position. Usage: MID(text, start_num, num_chars)
  22. MIN: Returns the lowest value from a list of values. Usage: MIN(value1, value2, …) 
  23. NOW: Returns the current date/time. Usage: NOW()
  24. OR: Use this function as an OR operator between a number of boolean(true/false) values. The function can receive two or more boolean(true/false) values and will return a boolean(true/false) Usage: OR(value1, value2, …)
  25. PARSEDATEEXACT: Use this function to convert a text into a Date, given a specific format. The function receives two parameters: the first one is the string representation of the date and the second one is a string representing the format. The function returns the parsed Date. Usage: PARSEDATEEXACT(date_string, format). Example: PARSEDATEEXACT(“July 12, 2035”, “MMMM dd, yyyy”)
  26. PARSEDATETIMEEXACT: Use this function to convert a text into a Date/Time, given a specific format, in local user timezone. The function receives two parameters: the first one is the string representation of the date/time and the second one is a string representing the format. The function returns the parsed Date/Time in local user timezone. Usage: PARSEDATETIMEEXACT(datetime_string, format). Example: PARSEDATETIMEEXACT(“July 12, 2035 11:45”, “MMMM dd, yyyy HH:mm”)
  27. PARSEDATETIMEGMTEXACT: Use this function to convert a text into a Date/Time, given a specific format, in GMT timezone. The function receives two parameters: the first one is the string representation of the date/time and the second one is a string representing the format. The function returns the parsed Date/Time in GMT timezone. Usage: PARSEDATETIMEGMTEXACT(datetime_string, format). Example: PARSEDATETIMEGMTEXACT(“July 12, 2035 11:45”, “MMMM dd, yyyy HH:mm”)
  28. RIGHT: Returns the specified number of characters from the end of a text string. Usage: RIGHT(text, num_chars)
  29. RIGHTBYTES: Cuts the end of a text to limit the byte size to a specified size. Usage: RIGHTBYTES(text, byte_size)
  30. SUBSTITUTE: Substitutes new text for old text in a text string. Usage: SUBSTITUTE(text, old_text, new_text)
  31. TODAY: Returns the current date. Usage: TODAY()
  32. UNESCAPEHTML: This function un-escapes HTML characters from the received value. For example, if the input parameter is “&lt;br&gt;”, the returned value is “<br>”. (Equivalent to Apex: String.unescapeHtml4()) Usage: UNESCAPEHTML(textvalue)
  33. UNESCAPEJAVA: This function returns a String whose Java literals are unescaped. Literals unescaped include escape sequences for quotes (\\”) and control characters, such as tab (\\t), and carriage return (\\n). (Equivalent to Apex: String.unescapeJava()) Usage: UNESCAPEJAVA(textvalue)
  34. URLDECODE: This function decodes a string in application/x-www-form-urlencoded format using a specific encoding scheme, for example ‘UTF-8’. You need to provide the string to decode and (optionally) the encoding scheme (default is ‘UTF-8’)  (Equivalent to Apex: EncodingUtil.urlDecode()) Usage: URLDECODE(textvalue) or URLDECODE(textvalue, ecodingScheme)
  35. URLENCODE: This function encodes a string in application/x-www-form-urlencoded format using a specific encoding scheme, for example ‘UTF-8’. You need to provide the string to encode and (optionally) the encoding scheme (default is ‘UTF-8’)  (Equivalent to Apex: EncodingUtil.urlEncode()) Usage: URLENCODE(textvalue) or URLENCODE(textvalue, ecodingScheme)