Published at: 2026-10-12
Formula Function Reference
Overview
This page summarizes the categories and usage of integration flow formula functions. The functions are organized into seven categories: type conversion, string operations, math operations, date and time, lists and collections, conditional logic, and formatting tools.
| Category | Count | Functions |
|---|---|---|
| 1. Type Conversion | 5 | toint / tonumber / tofloat / tostring / tobool |
| 2. String Operations | 16 | split / join / substring / contains / startsWith / endsWith / indexOf / replace_first / length / upper / lower / trim / capitalize / titleize / to_phone / smart_join |
| 3. Math Operations | 8 | round / max / min / sqrt / abs / ceil / floor / sum |
| 4. Date and Time | 14 | sysdate / now / ago / from_now / date_add / date2long / long2date / string_to_date / yweek / yday / wday / beginning_of_month / end_of_month / in_time_zone |
| 5. Lists and Collections | 11 | first / last / count / where / include / exclude / uniq / pluck / flatten / seq.add_all / tuple |
| 6. Conditional Logic | 4 | present / presence / blank / is_empty |
| 7. Formatting and Tools | 6 | format_map / to_currency / lookup / lookupMapping / parseJsonStr2Map |
1. Type Conversion
Converting between different data types is the most fundamental operation in an integration flow.
1. toint — Convert to integer
Syntax
toint(value)
Description
Converts any value to an integer (truncates the decimal part; does not round).
Example
| Input | Formula | Output |
|---|---|---|
String "5.1234" |
toint("5.1234") |
5 |
More examples
toint("42") → 42
toint(3.99) → 3 (truncates directly; does not round)
toint("abc") → 0 (returns 0 when parsing fails)
Tips
- Truncates the decimal directly, does not round. Use
math.roundwhen you need rounding - Returns
0for unconvertible values; check the source data carefully - If the source may be
nil, check withpresencefirst
2. tonumber — Convert to number
Syntax
tonumber(value)
Description
Converts a value to a number, supporting decimals. More general than
toint.Example
| Input | Formula | Output |
|---|---|---|
String "123.45" |
tonumber("123.45") |
123.45 |
More examples
tonumber("42") → 42
tonumber("3.14159") → 3.14159
tonumber("") → 0
Tips
- Preserves decimal precision
- Empty strings convert to
0 - Prefer
tointfor integers,tonumberwhen you need precision
3. tofloat — Convert to float
Syntax
tofloat(value)
Description
Converts a value to a floating-point number, similar to
tonumber.Example
| Input | Formula | Output |
|---|---|---|
String "3.14159" |
tofloat("3.14159") |
3.14159 |
More examples
tofloat("99.99") → 99.99
tofloat(42) → 42.0
tofloat("abc") → 0.0
Tips
tonumberandtofloatbehave essentially the same in daily use- Returns
0.0when parsing fails
4. tostring — Convert to string
Syntax
tostring(value)
Description
Converts any type of value to a string. Numbers, booleans, dates, and more can all be converted.
Example
| Input | Formula | Output |
|---|---|---|
Number 123 |
tostring(123) |
"123" |
Boolean true |
tostring(true) |
"true" |
More examples
tostring(3.14) → "3.14"
tostring(false) → "false"
tostring(nil) → "" (nil converts to empty string)
Tips
- Use
tostringfirst when type mismatch occurs during string concatenation nilbecomes an empty string""
5. tobool — Convert to boolean
Syntax
tobool(value)
Description
Converts a value to a boolean.
"true", 1, and "yes" (case-insensitive) are treated as true; everything else is false.Example
| Input | Formula | Output |
|---|---|---|
String "true" |
tobool("true") |
true |
String "yes" |
tobool("yes") |
true |
String "0" |
tobool("0") |
false |
More examples
tobool("TRUE") → true (case-insensitive)
tobool("YES") → true
tobool(1) → true
tobool(0) → false
tobool("no") → false
tobool("") → false
Tips
- Case-insensitive:
"TRUE"and"True"are both treated astrue "yes"and"YES"are also treated astrue- Everything except
true/1/yesisfalse
2. String Operations
String processing is the most used scenario in integration flows. Mastering these formulas handles 90% of data-cleaning needs.
6. string.split — Split a string
Syntax
string.split(string, separator)
Description
Splits a string into an array using a separator. The separator is removed.
Example
| Input | Formula | Output |
|---|---|---|
"a,b,c" |
string.split("a,b,c", ",") |
["a", "b", "c"] |
More examples
string.split("Zhang San,Li Si,Wang Wu", ",") → ["Zhang San", "Li Si", "Wang Wu"]
string.split("a|b|c", "|") → ["a", "b", "c"]
string.split("hello world", " ") → ["hello", "world"]
Tips
- The separator is removed from the result
- Supports regular expressions as the separator
- This is the same formula as Workato’s native
.split, just written differently
7. string.join — Join a string
Syntax
string.join(array, separator)
Description
Joins array elements into a single string using a separator. The reverse of
split.Example
| Input | Formula | Output |
|---|---|---|
["a", "b", "c"] |
string.join(["a", "b", "c"], ",") |
"a,b,c" |
More examples
string.join(["Zhang San", "Li Si"], "、") → "Zhang San、Li Si"
string.join(["2026", "07", "02"], "-") → "2026-07-02"
string.join([], ",") → ""
Tips
- The reverse of
split; the two are often used together - Empty arrays return an empty string
- The separator can be any string, such as
" - "or"、"
8. string.substring — Extract a substring
Syntax
string.substring(string, startIndex, endIndex)
Description
Extracts a substring from the specified range (left-closed, right-open). Indexes start at
0.Example
| Input | Formula | Output |
|---|---|---|
"hello world" |
string.substring("hello world", 0, 5) |
"hello" |
More examples
string.substring("hello world", 6, 11) → "world"
string.substring("1234567890", 0, 4) → "1234"
string.substring("hello", 1, -1) → "ell"
Tips
- Indexes start at
0; the range is left-closed and right-open[start, end) - Use a negative index or omit
endIndexto extract to the end - Commonly used to extract the last 4 digits of a phone number or identity information
9. string.contains — Check if a string contains
Syntax
string.contains(string, substring)
Description
Checks whether a string contains the specified substring, returning
true or false.Example
| Input | Formula | Output |
|---|---|---|
"hello world" |
string.contains("hello world", "world") |
true |
More examples
string.contains("Zhang San Feng", "Zhang") → true
string.contains("hello", "xyz") → false
string.contains("abc", "") → true (empty string always matches)
Tips
- Case-sensitive:
"Hello"does not contain"hello" - Commonly used in conditional branching
- An empty substring always returns
true
10. string.startsWith — Check if a string starts with
Syntax
string.startsWith(string, prefix)
Description
Checks whether a string starts with the specified prefix.
Example
| Input | Formula | Output |
|---|---|---|
"hello world" |
string.startsWith("hello world", "hello") |
true |
More examples
string.startsWith("CN13800138000", "CN") → true
string.startsWith("hello", "he") → true
string.startsWith("hello", "lo") → false
Tips
- Commonly used to check field prefixes and coding rules
- Case-sensitive
11. string.endsWith — Check if a string ends with
Syntax
string.endsWith(string, suffix)
Description
Checks whether a string ends with the specified suffix.
Example
| Input | Formula | Output |
|---|---|---|
"hello.txt" |
string.endsWith("hello.txt", ".txt") |
true |
More examples
string.endsWith("report.pdf", ".pdf") → true
string.endsWith("hello world", "world") → true
string.endsWith("hello", "he") → false
Tips
- Commonly used to check file extensions and URL suffixes
- Case-sensitive
12. string.indexOf — Find the substring position
Syntax
string.indexOf(string, substring)
Description
Returns the position where the substring first appears in the string (starting from 0); returns
-1 when not found.Example
| Input | Formula | Output |
|---|---|---|
"hello world" |
string.indexOf("hello world", "world") |
6 |
More examples
string.indexOf("hello world", "o") → 4
string.indexOf("hello", "xyz") → -1
string.indexOf("abcabc", "b") → 1 (the first occurrence)
Tips
- Indexes start at
0; the first character is at position0 - Returns
-1(not0) when not found - Usually paired with
string.contains: first check existence, then get the position
13. string.replace_first — Replace a substring
Syntax
string.replace_first(string, old, new)
Description
Replaces the first matching substring in a string.
Example
| Input | Formula | Output |
|---|---|---|
"hello world" |
string.replace_first("hello world", "world", "there") |
"hello there" |
More examples
string.replace_first("a-b-c-d", "-", "/") → "a/b-c-d" (replaces only the first)
string.replace_first("13800138000", "138", "CN") → "CN00138000"
Tips
- Replaces only the first match, not a global replacement
- For global replacement, call multiple times or combine with other methods
14. string.length — String length
Syntax
string.length(string)
Description
Counts the number of characters in a string.
Example
| Input | Formula | Output |
|---|---|---|
"hello" |
string.length("hello") |
5 |
More examples
string.length("Hello World") → 11
string.length("") → 0
string.length("a b c") → 5
Tips
- Each Chinese character counts as 1
- Spaces also count as 1
- Commonly used to validate phone number length (11 digits) and identity number length (18 digits)
15. string.upper — Convert to uppercase
Syntax
string.upper(string)
Description
Converts all letters in a string to uppercase.
Example
| Input | Formula | Output |
|---|---|---|
"hello world" |
string.upper("hello world") |
"HELLO WORLD" |
More examples
string.upper("Abc123") → "ABC123"
string.upper("hello world") → "HELLO WORLD"
Tips
- Only converts English letters; Chinese and numbers are unaffected
- Commonly used to unify code formats and case-insensitive comparisons
16. string.lower — Convert to lowercase
Syntax
string.lower(string)
Description
Converts all letters in a string to lowercase.
Example
| Input | Formula | Output |
|---|---|---|
"Hello World" |
string.lower("Hello World") |
"hello world" |
More examples
string.lower("ABC") → "abc"
string.lower("USER123") → "user123"
Tips
- The reverse of
string.upper - Commonly used for case-insensitive matching:
string.lower(a) == string.lower(b)
17. string.trim — Trim leading and trailing whitespace
Syntax
string.trim(string)
Description
Removes whitespace characters (spaces, tabs, newlines, and so on) from the beginning and end of a string.
Example
| Input | Formula | Output |
|---|---|---|
" hello " |
string.trim(" hello ") |
"hello" |
More examples
string.trim(" Zhang San ") → "Zhang San"
string.trim("\nhello\n") → "hello"
string.trim("a b c") → "a b c" (inner spaces are kept)
Tips
- Only removes leading and trailing whitespace; inner spaces are kept
- Almost always needed when importing data from external systems (Excel, forms, and so on)
- Can remove newline
\nand tab\tcharacters
18. capitalize — Capitalize the first letter
Syntax
capitalize(string)
Description
Converts the first character of a string to uppercase, leaving the rest unchanged.
Example
| Input | Formula | Output |
|---|---|---|
"hello world" |
capitalize("hello world") |
"Hello world" |
More examples
capitalize("john") → "John"
capitalize("ABC") → "ABC" (already all uppercase, unchanged)
capitalize("") → ""
Tips
- Only capitalizes the first letter, not every word (use
titleizefor per-word capitalization) - Unaffected when the string starts with a Chinese character
19. titleize — Capitalize each word
Syntax
titleize(string)
Description
Converts the first letter of each word in a string to uppercase.
Example
| Input | Formula | Output |
|---|---|---|
"hello world" |
titleize("hello world") |
"Hello World" |
More examples
titleize("john smith") → "John Smith"
titleize("HELLO WORLD") → "Hello World"
titleize("a tale of two") → "A Tale Of Two"
Tips
- Difference from
capitalize:capitalizeonly handles the first character of the whole string, whiletitleizehandles each word - Commonly used to format names and titles
20. to_phone — Filter phone characters
Syntax
to_phone(string)
Description
Filters a string, keeping only valid phone characters:
+, -, digits, and parentheses ().Example
| Input | Formula | Output |
|---|---|---|
"+86 138 1234 5678" |
to_phone("+86 138 1234 5678") |
"+8613812345678" |
More examples
to_phone("138-1234-5678") → "138-1234-5678"
to_phone("(010) 1234 5678") → "(010)12345678"
to_phone("Phone: 13800138000") → "13800138000"
Tips
- Automatically removes non-phone characters such as spaces and Chinese characters
+,-, and()are kept- Very useful for phone numbers imported from Excel or forms
21. smart_join — Smart join
Syntax
smart_join(array)
Description
Joins array elements with a space, automatically skipping empty strings and
nil, and trimming whitespace from each element.Example
| Input | Formula | Output |
|---|---|---|
["hello", "", "world"] |
smart_join(["hello", "", "world"]) |
"hello world" |
More examples
smart_join(["Zhang San", "", "Li Si"]) → "Zhang San Li Si"
smart_join(["a", " b ", "c"]) → "a b c"
smart_join(["", "", ""]) → ""
Tips
- Smarter than
string.join, handling empty values and whitespace automatically - The separator is fixed to a space
- Especially useful for concatenating names and addresses
3. Math Operations
Basic operations such as rounding, flooring, and summation.
22. math.round — Round
Syntax
math.round(number)
Description
Rounds a number to the nearest integer.
Example
| Input | Formula | Output |
|---|---|---|
3.6 |
math.round(3.6) |
4 |
More examples
math.round(3.4) → 3
math.round(3.5) → 4
math.round(-1.5) → -1
Tips
3.5rounds to4- Negative numbers follow the same rule
- Use
ceilorfloorwhen you need a specific number of decimal places
23. math.max — Maximum
Syntax
math.max(value1, value2, ...)
Description
Returns the maximum of all passed values.
Example
| Input | Formula | Output |
|---|---|---|
5, 12, 3 |
math.max(5, 12, 3) |
12 |
More examples
math.max(1, 2, 3, 4) → 4
math.max(-1, -5, -3) → -1
math.max(100, 50) → 100
Tips
- Accepts any number of arguments
- Commonly used to pick the larger of two values
24. math.min — Minimum
Syntax
math.min(value1, value2, ...)
Description
Returns the minimum of all passed values.
Example
| Input | Formula | Output |
|---|---|---|
5, 12, 3 |
math.min(5, 12, 3) |
3 |
More examples
math.min(1, 2, 3, 4) → 1
math.min(-1, -5, -3) → -5
Tips
- Pair with
math.maxto implement range limits
25. math.sqrt — Square root
Syntax
math.sqrt(number)
Description
Computes the square root of a number.
Example
| Input | Formula | Output |
|---|---|---|
9 |
math.sqrt(9) |
3.0 |
More examples
math.sqrt(16) → 4.0
math.sqrt(2) → 1.414...
math.sqrt(0) → 0.0
Tips
- Returns a floating-point number
- Negative numbers cause an error; ensure the value is ≥ 0 before calling
26. math.abs — Absolute value
Syntax
math.abs(number)
Description
Returns the absolute value of a number (removes the minus sign).
Example
| Input | Formula | Output |
|---|---|---|
-5 |
math.abs(-5) |
5 |
More examples
math.abs(10) → 10
math.abs(-3.14) → 3.14
math.abs(0) → 0
Tips
- Commonly used to compute differences and deviations
27. ceil — Round up
Syntax
ceil(number, precision)
Description
Rounds a number up to the specified precision. Without precision, rounds up to an integer (the smallest integer not less than the value).
Example
| Input | Formula | Output |
|---|---|---|
5.126 |
ceil(5.126, 2) |
5.13 |
More examples
ceil(5.126) → 6 (no precision, rounds up to integer)
ceil(5.129, 2) → 5.13
ceil(5.001, 2) → 5.01
ceil(-1.5) → -1
Tips
- Equivalent to rounding up to an integer when the second argument is omitted
- The second argument specifies the number of decimal places
- Commonly used for “at least N” calculations
28. floor — Round down
Syntax
floor(number, precision)
Description
Rounds a number down to the specified precision. Without precision, rounds down to an integer (the largest integer not greater than the value).
Example
| Input | Formula | Output |
|---|---|---|
5.129 |
floor(5.129, 2) |
5.12 |
More examples
floor(5.129) → 5 (no precision, rounds down to integer)
floor(5.999, 2) → 5.99
floor(-1.5) → -2
Tips
- The opposite of
ceil - Commonly used for “at most N” scenarios
29. sum — Sum
Syntax
sum(array)
Description
Sums all numeric elements in an array.
Example
| Input | Formula | Output |
|---|---|---|
[1, 2, 3, 4] |
sum([1, 2, 3, 4]) |
10 |
More examples
sum([10, 20, 30]) → 60
sum([]) → 0
sum([-1, 2, -3, 4]) → 2
Tips
- Empty arrays return
0 - Commonly used to total amounts and quantities
- Pair with
pluckto extract a field first, then sum
4. Date and Time
High-frequency operations in integration flows for timestamps, date format conversion, and time zone conversion.
30. sysdate — System date and time
Syntax
sysdate()
Description
Returns the current system date and time in the
yyyy-MM-dd HH:mm:ss format.Example
| Input | Formula | Output |
|---|---|---|
| (none) | sysdate() |
2026-04-02 10:00:00 |
Tips
- Requires no parameters
- Returns a formatted string, not a timestamp
- Use
nowwhen you need a timestamp
31. now — Current timestamp
Syntax
now()
Description
Returns the current system timestamp in milliseconds.
Example
| Input | Formula | Output |
|---|---|---|
| (none) | now() |
1743565200000 (current timestamp) |
Tips
- Returns a millisecond timestamp (13 digits)
- Commonly used to compute time differences and record operation times
- Convert to a readable date with
long2date
32. ago — Past time
Syntax
ago(amount, unit)
Description
Computes the timestamp at a specified amount of time before now.
unit supports "day", "hour", "minute", "second", "month", "year", and so on.Example
| Input | Formula | Output |
|---|---|---|
| 3 days ago | ago(3, "day") |
1743523200000 (timestamp 3 days before now) |
More examples
ago(1, "hour") → timestamp one hour ago
ago(7, "day") → timestamp seven days ago
ago(1, "month") → timestamp one month ago
Tips
- Common scenarios: querying the last 7 days, getting yesterday’s timestamp
- Pair with
from_nowto represent a time range
33. from_now — Future time
Syntax
from_now(amount, unit)
Description
Computes the timestamp at a specified amount of time after now. The “future” version of
ago.Example
| Input | Formula | Output |
|---|---|---|
| 3 days later | from_now(3, "day") |
1743955200000 (timestamp 3 days after now) |
More examples
from_now(1, "hour") → timestamp one hour later
from_now(30, "minute") → timestamp 30 minutes later
from_now(1, "year") → timestamp one year later
Tips
- The opposite direction of
ago - Commonly used to set deadlines and expiry times
34. date_add — Add or subtract a date
Syntax
date_add(timestamp, amount, unit)
Description
Adds or subtracts an amount of time to a given timestamp.
unit supports "day", "month", "year", "hour", and so on.Example
| Input | Formula | Output |
|---|---|---|
| Add 5 days to a date | date_add(1743523200000, 5, "day") |
1743955200000 |
More examples
date_add(1743523200000, -1, "day") → 1743436800000 (subtract one day)
date_add(1743523200000, 1, "month") → 1746035200000 (add one month)
date_add(1743523200000, 1, "year") → 1775059200000 (add one year)
Tips
amountcan be negative to subtract- More flexible than
ago/from_now, computing from any timestamp
35. date2long — Date to timestamp
Syntax
date2long(dateString, format, unit)
Description
Converts a date string to a timestamp according to the specified format.
Example
| Input | Formula | Output |
|---|---|---|
"2026-04-02 10:00:00" |
date2long("2026-04-02 10:00:00", "yyyy-MM-dd HH:mm:ss", "ms") |
1743565200000 |
More examples
date2long("2026-04-02", "yyyy-MM-dd", "ms") → 1743523200000
date2long("04/02/2026", "MM/dd/yyyy", "ms") → 1743523200000
date2long("20260402", "yyyyMMdd", "ms") → 1743523200000
Tips
- The third parameter
unit:"ms"means milliseconds,"s"means seconds formatmust match the actual format of the date string- Common format symbols:
yyyy=year,MM=month,dd=day,HH=hour,mm=minute,ss=second
36. long2date — Timestamp to date
Syntax
long2date(timestamp, format, unit)
Description
Converts a timestamp to a readable date string according to the specified format. The reverse of
date2long.Example
| Input | Formula | Output |
|---|---|---|
1743565200000 |
long2date(1743565200000, "yyyy-MM-dd HH:mm:ss", "ms") |
"2026-04-02 10:00:00" |
More examples
long2date(1743565200000, "yyyy-MM-dd", "ms") → "2026-04-02"
long2date(1743565200000, "yyyy-MM-dd HH:mm:ss", "ms") → "2026-04-02 10:00:00"
The format string is customizable; for example,
yyyyMMdd outputs 20260402.Tips
- The reverse of
date2long; the two are a pair formatcan be any custom format
37. string_to_date — String to date
Syntax
string_to_date(dateString, format)
Description
Parses a string into a date object according to the specified format.
Example
| Input | Formula | Output |
|---|---|---|
"2026-04-02" |
string_to_date("2026-04-02", "yyyy-MM-dd") |
2026-04-02 00:00:00 |
More examples
string_to_date("2026-04-02", "yyyy-MM-dd") → 2026-04-02 00:00:00
string_to_date("20260402", "yyyyMMdd") → 2026-04-02 00:00:00
Tips
- Returns a date object, not a timestamp
- Use this when you only need date comparison, not a timestamp
38. yweek — Week of the year
Syntax
yweek(timestamp)
Description
Returns which week of the year a date falls in (1-53).
Example
| Input | Formula | Output |
|---|---|---|
1743523200000 |
yweek(1743523200000) |
14 (April 2, 2026 is the 14th week of the year) |
More examples
yweek(now()) → the current week of the year
Tips
- Returns an integer from 1 to 53
- Commonly used for weekly reports
39. yday — Day of the year
Syntax
yday(timestamp)
Description
Returns which day of the year a date falls on (1-366).
Example
| Input | Formula | Output |
|---|---|---|
1743523200000 |
yday(1743523200000) |
92 (April 2, 2026 is the 92nd day of the year) |
More examples
yday(now()) → the current day of the year
Tips
- January 1 is day 1
- Leap years go up to 366
40. wday — Day of the week
Syntax
wday(timestamp)
Description
Returns the day of the week. Sunday = 0, Monday = 1, …, Saturday = 6.
Example
| Input | Formula | Output |
|---|---|---|
1743523200000 |
wday(1743523200000) |
4 (April 2, 2026 is a Thursday) |
More examples
wday(now()) → today's day of the week (as a number)
Tips
- The week starts at 0: Sunday is 0, Monday is 1
- Check for weekdays:
wday(now()) >= 1 and wday(now()) <= 5
41. beginning_of_month — Start of the month
Syntax
beginning_of_month(timestamp)
Description
Returns the timestamp of the first day of the month at 00:00:00.
Example
| Input | Formula | Output |
|---|---|---|
1743523200000 |
beginning_of_month(1743523200000) |
1748966400000 (May 1, 2026 00:00:00) |
More examples
beginning_of_month(now()) → timestamp of the first day of this month at 00:00:00
Tips
- Note: the example input is an April date, but it returns May 1
- Commonly used as the start time for monthly queries
42. end_of_month — End of the month
Syntax
end_of_month(timestamp)
Description
Returns the timestamp of the last day of the month at 23:59:59.
Example
| Input | Formula | Output |
|---|---|---|
1748966400000 |
end_of_month(1748966400000) |
1751366399000 (May 31, 2026 23:59:59) |
More examples
end_of_month(now()) → timestamp of the last day of this month at 23:59:59
Tips
- Returns 23:59:59, covering the last second
- Pair with
beginning_of_monthto define a monthly time range
43. in_time_zone — Time zone conversion
Syntax
in_time_zone(timestamp, fromZone, toZone)
Description
Converts a timestamp from one time zone to another, returning the converted timestamp.
Example
| Input | Formula | Output |
|---|---|---|
| Shanghai → New York | in_time_zone(1743523200000, "Asia/Shanghai", "America/New_York") |
1743494640000 |
More examples
in_time_zone(now(), "Asia/Shanghai", "Asia/Tokyo") → Tokyo time
in_time_zone(now(), "Asia/Shanghai", "Europe/London") → London time
Tips
- Use standard time zone names:
"Asia/Shanghai","America/New_York", and so on - Returns a timestamp, so format it with
long2date
5. Lists and Collections
Data in integration flows often appears as arrays or lists. These formulas help you process them efficiently.
44. first — Get the first element
Syntax
first(array, n?)
Description
Gets the first element of a list. If you pass the second argument
n, returns an array of the first n elements.Example
| Input | Formula | Output |
|---|---|---|
[1, 2, 3] |
first([1, 2, 3]) |
1 |
[1, 2, 3] |
first([1, 2, 3], 2) |
[1, 2] |
More examples
first(["Zhang San", "Li Si", "Wang Wu"]) → "Zhang San"
first(["Zhang San", "Li Si", "Wang Wu"], 1) → ["Zhang San"] (passing 1 returns an array)
first([]) → nil
Tips
- Empty arrays return
nil; handle null values carefully - The return type differs with and without
n: the former returns an element, the latter an array - Very common when getting the latest record from a list
45. last — Get the last element
Syntax
last(array, n?)
Description
Gets the last element of a list. If you pass the second argument
n, returns the last n elements.Example
| Input | Formula | Output |
|---|---|---|
[1, 2, 3] |
last([1, 2, 3]) |
3 |
[1, 2, 3] |
last([1, 2, 3], 2) |
[2, 3] |
More examples
last(["Zhang San", "Li Si", "Wang Wu"]) → "Wang Wu"
last([]) → nil
Tips
- Similar to
first, empty arrays returnnil - Commonly used to get the latest record
46. count — Count
Syntax
count(array)
Description
Returns the number of elements in an array or collection.
Example
| Input | Formula | Output |
|---|---|---|
[1, 2, 3, 4] |
count([1, 2, 3, 4]) |
4 |
More examples
count([]) → 0
count(["a", "b"]) → 2
count("hello") → 5 (works on strings too)
Tips
- Works on strings too, returning the character count
- Empty arrays return
0
47. where — Conditional filter
Syntax
where(array, condition)
Description
Filters a list by condition, keeping only elements that satisfy it. Use
item to refer to the current element in the condition.Example
| Input | Formula | Output |
|---|---|---|
[1, 2, 3, 4] |
where([1, 2, 3, 4], "item > 2") |
[3, 4] |
More examples
where([1, 2, 3, 4], "item % 2 == 0") → [2, 4] (even numbers)
where(["a", "ab", "abc"], "string.length(item) > 1") → ["ab", "abc"]
Tips
- Always use
itemto refer to the current element in the condition - The condition is written like a boolean expression in programming
- Object arrays can be filtered by field:
"item.age > 18"
48. include — Check if included
Syntax
include(array, value)
Description
Checks whether an array or string contains the specified element or substring.
Example
| Input | Formula | Output |
|---|---|---|
[1, 2, 3] |
include([1, 2, 3], 2) |
true |
More examples
include(["Zhang San", "Li Si"], "Zhang San") → true
include("hello", "he") → true
include([1, 2, 3], 5) → false
Tips
- Equivalent to
string.containswhen used on a string - Checks element existence when used on an array
49. exclude — Check if excluded
Syntax
exclude(collection, value)
Description
Checks whether a string or array does not contain the specified element. The reverse of
include.Example
| Input | Formula | Output |
|---|---|---|
"hello world" |
exclude("hello world", "wor") |
false (because it contains "wor") |
"hello" |
exclude("hello", "xyz") |
true |
More examples
exclude([1, 2, 3], 5) → true (does not contain 5)
exclude(["Zhang San"], "Zhang San") → false (contains)
Tips
exclude(x, y)equals!include(x, y)- Easy to reason about: exclude = not included
50. uniq — Deduplicate
Syntax
uniq(array)
Description
Returns an array of unique elements, automatically removing duplicates.
Example
| Input | Formula | Output |
|---|---|---|
[1, 2, 2, 3, 1] |
uniq([1, 2, 2, 3, 1]) |
[1, 2, 3] |
More examples
uniq(["a", "b", "a", "c"]) → ["a", "b", "c"]
uniq([1]) → [1]
uniq([]) → []
Tips
- Preserves the order of first occurrence
- Empty arrays return an empty array
51. pluck — Extract a field
Syntax
pluck(array, fieldName)
Description
Extracts the value of the specified field from an array of objects, returning a new array.
Example
| Input | Formula | Output |
|---|---|---|
[{"name": "Zhang San"}, {"name": "Li Si"}] |
pluck([{"name": "Zhang San"}, {"name": "Li Si"}], "name") |
["Zhang San", "Li Si"] |
More examples
pluck([{"age": 25}, {"age": 30}], "age") → [25, 30]
pluck([{"name": "Zhang San", "age": 25}], "name") → ["Zhang San"]
Tips
- A very high-frequency formula used in almost every integration flow
- Often chained with
sum,where, anduniq
52. flatten — Flatten
Syntax
flatten(array)
Description
Flattens nested arrays (two-dimensional, three-dimensional, and so on) into a one-dimensional array.
Example
| Input | Formula | Output |
|---|---|---|
[[1, 2], [3, [4, 5]]] |
flatten([[1, 2], [3, [4, 5]]]) |
[1, 2, 3, 4, 5] |
More examples
flatten([[1], [2, 3], [4]]) → [1, 2, 3, 4]
flatten([1, 2, 3]) → [1, 2, 3] (already flat, unchanged)
Tips
- Handles multi-level nesting, recursively flattening all levels
- Commonly used after aggregating data from multiple APIs
53. seq.add_all — Concatenate lists
Syntax
seq.add_all(array1, array2)
Description
Concatenates two lists into one.
Example
| Input | Formula | Output |
|---|---|---|
[1, 2] and [3, 4] |
seq.add_all([1, 2], [3, 4]) |
[1, 2, 3, 4] |
More examples
seq.add_all(["a"], ["b", "c"]) → ["a", "b", "c"]
seq.add_all([], [1, 2]) → [1, 2]
Tips
- Supports only two arrays; call multiple times for more
- Essentially concatenates two arrays end to end
54. tuple — Build a collection
Syntax
tuple(value1, value2, ...)
Description
Assembles multiple values into an array in order.
Example
| Input | Formula | Output |
|---|---|---|
1, 2, 3 |
tuple(1, 2, 3) |
[1, 2, 3] |
More examples
tuple("Zhang San", 25, true) → ["Zhang San", 25, true]
tuple(a, b) → [value of a, value of b]
Tips
- Can mix different types
- Commonly used to combine scattered variables into one array for further processing
6. Conditional Logic
Used for conditional branching, data validation, and null handling.
55. present — Existence check
Syntax
present(value)
Description
Checks whether a value “exists” (not
nil, not an empty string, not false, not an empty collection). Returns true if it exists, otherwise false.Example
| Input | Formula | Output |
|---|---|---|
"hello" |
present("hello") |
true |
"" |
present("") |
false |
More examples
present(0) → true (0 is a valid value, exists)
present(nil) → false
present([]) → false (empty array does not "exist")
present(" ") → true (a whitespace string is not empty)
Tips
- Mutually exclusive with
blank:present(x)equals!blank(x) 0and" "(whitespace) are considered present; this is a common pitfall- Commonly used in if branches: “continue only when the field has a value”
56. presence — Return the value if present
Syntax
presence(value)
Description
Returns the original value if it exists (non-empty), otherwise returns
nil.Example
| Input | Formula | Output |
|---|---|---|
"hello" |
presence("hello") |
"hello" |
"" |
presence("") |
nil |
More examples
presence(nil) → nil
presence("Zhang San") → "Zhang San"
presence(0) → 0 (0 is considered present, returns the original value)
Tips
- Difference from
present:presentreturns a boolean, whilepresencereturns the original value ornil - Commonly used to provide a default value:
presence(field) or "default"
57. blank — Blank check
Syntax
blank(value)
Description
Checks whether a value is blank (
nil, empty string, false, empty collection). Returns true if blank.Example
| Input | Formula | Output |
|---|---|---|
"" |
blank("") |
true |
"hello" |
blank("hello") |
false |
More examples
blank(nil) → true
blank(false) → true
blank([]) → true
blank(0) → false
blank(" ") → false (whitespace is not blank)
Tips
- Mutually exclusive with
present blank(0)returnsfalse, which differs from some languages- Commonly used for data validation: “error when the field is blank”
58. is_empty — Check if empty
Syntax
is_empty(value)
Description
Checks whether a collection or string is empty.
Example
| Input | Formula | Output |
|---|---|---|
[] |
is_empty([]) |
true |
"hello" |
is_empty("hello") |
false |
More examples
is_empty("") → true
is_empty([1, 2, 3]) → false
Tips
- Similar to
blank, but the logic is slightly narrower present/blankare more commonly used in daily work
7. Formatting and Tools
Practical utility formulas for data formatting, mapping lookup, and JSON parsing.
59. format_map — Format mapping
Syntax
format_map(template, objectArray)
Description
Maps an array of objects into a list of formatted strings using a template, supporting
%{fieldName} placeholders.Example
| Input | Formula | Output |
|---|---|---|
Object array [{"name":"Zhang San","age":13}] |
format_map("His name is %{name}, age is %{age}.", obj) |
["His name is Zhang San, age is 13."] |
More examples
format_map("%{name} - %{amount} yuan", [{"name":"Product A", "amount":100}, {"name":"Product B", "amount":200}])
→ ["Product A - 100 yuan", "Product B - 200 yuan"]
Tips
%{fieldName}is replaced with the value of the corresponding field in the object- Useful for batch-generating formatted text, such as notification messages and report rows
- Maps multiple objects at once, returning an array
60. to_currency — Currency formatting
Syntax
to_currency(number, symbol?, precision?)
Description
Formats a number as currency (adding thousands separators and a currency symbol). Defaults to the RMB symbol
¥.Example
| Input | Formula | Output |
|---|---|---|
1234.56 |
to_currency(1234.56) |
"¥1,234.56" |
1234.56 |
to_currency(1234.56, "$", 2) |
"$1,234.56" |
More examples
to_currency(1000000) → "¥1,000,000.00"
to_currency(99.9, "€", 2) → "€99.90"
Tips
- The default currency symbol is
¥(RMB) - Automatically adds thousands separators
- Commonly used for quotations and invoices
61. lookup — Lookup table
Syntax
lookup(map, key)
Description
Looks up the value for a key in a Map (key-value pairs).
Example
| Input | Formula | Output |
|---|---|---|
{"name": "Zhang San", "age": 25} |
lookup({"name": "Zhang San", "age": 25}, "name") |
"Zhang San" |
More examples
lookup({"status": "Approved", "code": 200}, "code") → 200
lookup({"a": 1}, "b") → nil (key does not exist)
Tips
- Returns
nilwhen the key does not exist - Similar to
map[key]in programming - Commonly used to read values from configuration objects
62. lookupMapping — Look up a mapping object
Syntax
lookupMapping(objectName, mappingCategory, mappingValue, convertType)
Description
Finds a matching record from the data mapping object and returns
_id. Parameters include: object name, mapping category, mapping value, and conversion type.Example
| Input | Formula | Output |
|---|---|---|
| Department mapping | lookupMapping("bound object (read-only)", "department mapping", "R&D", "1") |
"12345" (returns the ID of the matching record) |
Tips
- This is a platform-specific formula that depends on the data mapping table configured on the platform
- You must establish the mapping relationship on the platform before using it
- Commonly used for data dictionary conversion between systems
63. parseJsonStr2Map — JSON string to Map
Syntax
parseJsonStr2Map(jsonString)
Description
Parses a JSON-formatted string into a Map object for later processing with formulas such as
lookup.Example
| Input | Formula | Output |
|---|---|---|
'{"name":"Zhang San","age":13}' |
parseJsonStr2Map('{"name":"Zhang San","age":13}') |
{name: "Zhang San", age: 13} |
More examples
parseJsonStr2Map('{"status":"ok","data":[1,2,3]}')
→ {status: "ok", data: [1, 2, 3]}
Tips
- The JSON string must be valid JSON
- After parsing, access internal data with
lookupor.fieldName - API responses are often JSON strings; this formula is the first step of parsing
Appendix: Common Combinations
The following are the easiest formula combinations for junior developers to get started with:
Pattern 1: Extract data from an API response
Parse JSON → extract fields → format output
parseJsonStr2Map(resp) → pluck(data, "name") → format_map("Name: %{name}", ...)
Pattern 2: Date range filtering
Get time range → filter data
beginning_of_month(now()) ~ end_of_month(now()) → where(items, "item.date >= start and item.date <= end")
Pattern 3: Null-safe handling
presence(field) or "default value"
Pattern 4: Data cleaning pipeline
Trim → filter empty values → deduplicate
string.trim(field) → where(list, "not blank(item)") → uniq(list)
Pattern 5: String ↔ array conversion
String → split → [array processing] → join → string
"a,b,c" → ["a","b","c"] → dedupe/filter/sort → "a,b"
Tip: It is recommended to test each formula hands-on in an actual integration flow. When you encounter an error, first check whether the parameter types match and whether null values are handled.