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:Data Access Functions
data(field)
Retrieves a value from the current record.| Parameter | Type | Description |
|---|---|---|
field | string | The field name to retrieve |
findvalue(array, filterArray, key, default)
Finds a value in an array of objects based on filter criteria.| Parameter | Type | Description |
|---|---|---|
array | array | The array to search |
filterArray | array | Key-value pairs to match |
key | string | The field to return from the matched object |
default | any | Optional default value if no match found |
key from the first matching object, or default if no match.
vlookup(field, objectName, objectField, fieldLookup)
Looks up a value from another Connect Object.| Parameter | Type | Description |
|---|---|---|
field | string | The field containing the lookup key |
objectName | string | The Connect Object to search |
objectField | string | The field in the object to match against |
fieldLookup | string | The field to return |
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).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).get_entity_data(entityName, filters)
Retrieves records from a Connect Object with optional filters. Results are returned ordered bycreated_at descending (newest first).
| Parameter | Type | Description |
|---|---|---|
entityName | string | The Connect Object name |
filters | array | Array of filter conditions: [field, operator, value] |
String Functions
concat(value1, value2, …)
Concatenates multiple values into a single string. Examples:mid(text, start, length)
Extracts a substring from text.| Parameter | Type | Description |
|---|---|---|
text | string | The source text |
start | number | Starting position (1-based) |
length | number | Number of characters to extract |
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, orfalse 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.| Parameter | Type | Description |
|---|---|---|
number | number | The number to pad |
digits | number | Desired total length |
character | string | Padding character (default: ‘0’) |
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.| Parameter | Type | Description |
|---|---|---|
date | string | The date to format |
format | string | PHP date format string |
Y- 4-digit yearm- 2-digit monthd- 2-digit dayH- 24-hour houri- Minutess- Seconds
timeformat(hours, minutes, seconds, format)
Formats time components. Example:Conditional Functions
if(condition, trueValue, falseValue)
Returns different values based on a condition. Examples: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’sempty() 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.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.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’sempty() 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.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.| Parameter | Type | Description |
|---|---|---|
array | array | Input array |
fieldMappingsJson | string | JSON string defining the mapping |
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’sFILTER_VALIDATE_BOOLEAN, which understands string representations of booleans.
Recognized values:
- True:
"true","yes","on","1",1,true - False:
"false","no","off","0",0,false
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.| Parameter | Type | Description |
|---|---|---|
code | string | Sequence identifier |
digits | string | Number of digits (default: ‘08’) |
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.| Parameter | Type | Description |
|---|---|---|
field | string | The field name to read from |
firstChar | string | The opening character to search for |
firstNum | number | Which occurrence of the opening character (1 = first) |
lastChar | string | The closing character to search for |
lastNum | number | Which occurrence of the closing character (1 = first) |
extractvalues(pattern, input, matchIndex, index)
Extracts values using regex. Example:Common Formula Patterns
Handling Null Values
Formatting Names
Conditional Field Value
Looking Up Related Data
Extracting from Nested Arrays
Date Formatting
Generating Unique IDs
Tips and Best Practices
Test Formulas Incrementally
Test Formulas Incrementally
Start with simple formulas and add complexity gradually. Test each step to ensure data flows correctly.
Handle Nulls Explicitly
Handle Nulls Explicitly
External data often contains null values. Use
ifempty(), nullif(), or if(isblank()) to handle them gracefully.Use Meaningful Default Values
Use Meaningful Default Values
When providing defaults, use values that make sense for your business logic rather than empty strings.
Keep Formulas Readable
Keep Formulas Readable
Break complex formulas into multiple mapping rows when possible, using intermediate fields.
Related Documentation
Inbound Connections
Use formulas in inbound field mapping
Outbound Connections
Use formulas in outbound field mapping
Connect Objects
Define fields for formula reference
