Skip to main content

Overview

The Formula language in Fentu Connect allows you to transform, calculate, and manipulate data during field mapping. Formulas can combine multiple source fields, apply conditional logic, look up related data, and format values.
Formulas are case-insensitive. You can write data(), DATA(), or Data() - they all work the same.

Basic Syntax

Formulas use function-based syntax with parentheses:
You can nest functions:

Data Access Functions

data(field)

Retrieves a value from the current record. Examples:
Returns: The field value, or null if the field doesn’t exist.

findvalue(array, filterArray, key, default)

Finds a value in an array of objects based on filter criteria. Examples:
Returns: The value of key from the first matching object, or default if no match.

vlookup(field, objectName, objectField, fieldLookup)

Looks up a value from another Connect Object. Example:
Returns: The lookup field value, or null if no match.

textvlookup(text, objectName, objectField, fieldLookup)

Like vlookup but accepts a direct text value (or formula result) instead of a field name. This is essential for chaining lookups — passing the result of one lookup into another.
When multiple records match, textvlookup returns the most recently updated one (ordered by updated_at descending).
Examples:
Chaining pattern — resolve a value through multiple tables:

textvlookuplike(text, objectName, objectField, fieldLookup)

Like textvlookup but uses case-insensitive partial matching (ILIKE ‘%text%’).
Unlike textvlookup, textvlookuplike returns the oldest match (ordered by updated_at ascending).
Example:

get_entity_data(entityName, filters)

Retrieves records from a Connect Object with optional filters. Results are returned ordered by created_at descending (newest first). Example:

String Functions

concat(value1, value2, …)

Concatenates multiple values into a single string. Examples:

mid(text, start, length)

Extracts a substring from text. Example:

len(text)

Returns the length of a text string. Example:

trim(text)

Removes leading and trailing whitespace. Example:

replace(search, replace, subject)

Replaces text in a string. (Note: parameter order follows PHP str_replace) Example:

begins(text, match)

Checks if text starts with a specific string. Example:

find(char, text)

Finds the position of a character in text. Returns a 1-based position, or false if not found. Example:

striptags(text)

Removes HTML tags from text. Example:

splitindex(text, delimiter, index)

Splits text by delimiter and returns the element at index. Example:

leadingcharacters(number, digits, character)

Pads a number with leading characters. Example:

Date and Time Functions

now()

Returns the current date and time. Example:

today()

Returns the current date (without time). Example:

year(date)

Extracts the year from a date. Example:

month(date)

Extracts the month from a date (01-12). Example:

day(date)

Extracts the day from a date (01-31). Example:

date(year, month, day)

Creates a date from components. Example:

datetimeformat(date, format)

Formats a date/time string. Common format codes:
  • Y - 4-digit year
  • m - 2-digit month
  • d - 2-digit day
  • H - 24-hour hour
  • i - Minutes
  • s - Seconds
Example:

timeformat(hours, minutes, seconds, format)

Formats time components. Example:

Conditional Functions

if(condition, trueValue, falseValue)

Returns different values based on a condition.
The if() function uses PHP truthiness for the condition. This means "0", 0, "", null, and false are all treated as false. If a field could legitimately contain "0" as a valid value, use an explicit comparison like != null instead of a bare truthy check.
Examples:
When checking if a lookup returned a value, prefer ifempty() over if() to avoid repeating the lookup:

case(value, match1, result1, match2, result2, …, default)

Switch/case statement - returns result for first matching value. Example:

ifempty(value1, value2)

Returns value2 if value1 is empty. Uses PHP’s empty() check internally.
Like isblank(), this treats "0", 0, "", null, false, and [] as empty. If "0" is a valid value in your data, use if(value != null, value, fallback) instead.
Example:

nullif(field)

Returns the field value or null if empty. Takes a field name (not a value) and reads directly from the current record.
Uses PHP’s empty() check — "0", 0, "", and null all return null.
Example:

or(value1, value2, …)

Logical OR - returns true if any value is true. Example:

and(value1, value2, …)

Logical AND - returns true only if all values are true. Example:

not(value)

Logical NOT - inverts a boolean value. Example:

isblank(value)

Returns true if value is empty/null. Maps directly to PHP’s empty() function.
empty() in PHP treats ALL of the following as blank: null, "", "0", 0, false, []. If you need to distinguish between null and "0", use an explicit == null comparison instead.
Example:

isnumber(value)

Returns true if value is numeric. Example:

ispickval(value, compareValue)

Checks if value equals compareValue. Example:

Array Functions

maparray(array, fieldMappingsJson)

Transforms an array of objects using field mappings. Example:

setarray(array, value, key)

Sets a value for all items in an array. Example:

getobjectarray(object, key, default)

Gets a value from an object/array by key. Example:

reversearray(array)

Reverses an array. Example:

upsert_array(array, search, replace)

Updates or inserts values in an array. Example:

merge_array_by_key(array1, array2, key)

Merges two arrays by matching a key field. Example:

explode(delimiter, string)

Splits a string into an array. Example:

implode(glue, array)

Joins an array into a string. Example:

JSON Functions

jsondecode(jsonString, default)

Parses a JSON string into an array. Always returns arrays (not objects). Example:

get_json_value(jsonText, key)

Gets a value from JSON using dot notation. Example:

Utility Functions

text(value)

Converts a value to string. Example:

bool(field)

Converts a field to boolean. Takes a field name (not a value) and reads from the current record. Uses PHP’s FILTER_VALIDATE_BOOLEAN, which understands string representations of booleans. Recognized values:
  • True: "true", "yes", "on", "1", 1, true
  • False: "false", "no", "off", "0", 0, false
Example:

email(field)

Extracts an email address from text. Takes a field name (not a value) and reads from the current record. Uses regex to find the first email address in the field’s text content. Example:

runnumber(code, digits)

Generates a running number sequence. Example:

setdata(field, value)

Sets a value in the data context and returns it. Example:

extractstring(field, firstChar, firstNum, lastChar, lastNum)

Extracts text between the nth occurrence of two characters. Takes a field name and reads from the current record. Example:

extractvalues(pattern, input, matchIndex, index)

Extracts values using regex. Example:

Common Formula Patterns

Handling Null Values

Formatting Names

Conditional Field Value

Extracting from Nested Arrays

Date Formatting

Generating Unique IDs


Tips and Best Practices

Start with simple formulas and add complexity gradually. Test each step to ensure data flows correctly.
External data often contains null values. Use ifempty(), nullif(), or if(isblank()) to handle them gracefully.
When providing defaults, use values that make sense for your business logic rather than empty strings.
Break complex formulas into multiple mapping rows when possible, using intermediate fields.

Inbound Connections

Use formulas in inbound field mapping

Outbound Connections

Use formulas in outbound field mapping

Connect Objects

Define fields for formula reference