TIB Flogo 2.25.0 Mapper Functions Guide
TIB Flogo 2.25.0 Mapper Functions Guide
TIB Flogo 2.25.0 Mapper Functions Guide
Contents
Contents 2
Array Functions 12
array.append 12
array.contains 13
array.count 14
array.create 15
array.delete 15
array.flatten 16
array.forEach 17
array.get 19
array.merge 20
array.reverse 20
array.slice 21
array.sum 22
Boolean Functions 24
boolean.false 24
boolean.not 24
boolean.true 25
Coerce Functions 27
coerce.toArray 27
coerce.toBool 28
coerce.toBytes 28
Coerce.toFloat32 29
Coerce.toFloat64 30
coerce.toInt 31
Coerce.toInt32 31
Coerce.toInt64 32
coerce.toObject 33
coerce.toParams 34
coerce.toString 34
coerce.toType 35
Compression Functions 37
compression.gzipCompress 37
compression.gzipUncompress 38
Data Functions 39
data.GetValue 39
data.isDefined 40
Datetime Functions 42
datetime.add 42
datetime.addHours 43
datetime.addMins 44
datetime.addSeconds 44
datetime.create 45
datetime.current 46
datetime.currentDate 47
datetime.currentDatetime 48
datetime.currentTime 49
datetime.diff 49
datetime.format 50
datetime.formatDate 52
datetime.formatDatetime 52
datetime.formatTime 53
datetime.now 54
datetime.parse 55
Datetime.sub 56
datetime.subHours 57
datetime.subMins 58
Datetime.subSeconds 58
Float Functions 60
float.float64 60
JSON Functions 61
json.exists 61
json.get 62
json.length 63
json.numbersToString 64
json.objKeys 65
json.objValues 66
json.path 67
json.jq 69
json.set 70
Math Functions 72
math.ceil 72
math.floor 73
math.isNaN 73
math.mod 74
math.round 75
math.roundToEven 76
math.trunc 76
Number Functions 78
number.int64 78
number.len 79
number.random 79
String Functions 81
String.base64ToString 81
string.concat 82
string.contains 82
string.containsAny 83
string.count 84
string.dateFormat 85
string.lastIndex 86
string.datetimeFormat 87
string.endsWith 87
string.equals 88
string.equalsIgnoreCase 89
string.float 90
string.index 91
string.indexAny 92
string.integer 92
string.join 93
string.len 94
string.length 95
string.lowerCase 96
string.matchRegEx 96
string.regex 97
string.repeat 98
string.replace 99
string.replaceAll 100
string.replaceRegEx 101
string.split 102
string.startsWith 103
String.stringToBase64 104
string.substring 105
string.substringAfter 106
string.substringBefore 107
string.timeFormat 108
string.toLower 108
string.toTitleCase 109
string.toUpper 110
string.tostring 111
string.trim 111
string.trimLeft 112
string.trimPrefix 113
string.trimRight 114
string.trimSuffix 115
string.upperCase 116
Utils.decodeBase64 128
Utils.encodeBase64 129
utils.uuid 129
Important: For general information about the data mapper and how to use it,
see the Data Mappings.
The mapper provides commonly used functions that you can use along with the data to be
mapped. The functions are grouped into the following logical categories:
Category Description
Category Description
Using Functions
You can use a function from the list of functions available under Functions in the mapper.
Input parameters to the function can either be mapped from an element under Available
data, a literal value, or an expression that evaluates to the appropriate data type or any
combination of them.
The procedure below illustrates an example that concatenates two strings and assigns the
concatenated value to the message. We manually enter a value for the first string (str1)
and map the second string to id under $flow. The value for id comes from the flow input.
Procedure
1. Click the message to open the text editor to the right.
2. Click Functions. Expand the string function group and click concat(str1, str2).
3. Select str1 in the function and type "Received: " (be sure to include the double
quotes as shown below) to replace str1 with it.
At run time, the output from the concat function is mapped to the message.
Array Functions
This section provides a quick reference to the Flogo array functions.
array.append
This function appends an item to an existing array.
Syntax
array.append(items, item)
Arguments
Returns
Type Description
array of type any Existing array with new item appended to it.
Examples
l The function array.append($Activity[xxx].array, "new Item") returns
array.contains
This function checks whether the specified item is found in the specified array.
Syntax
array.contains(array, item)
Arguments
array array of type The array in which the specified item needs to be searched.
any
NOTE: The type of the item must match the type of the
array.
Returns
Type Description
Examples
The function array.contains(array.create("A","B","C"), "B") returns true.
array.count
This function counts the length of an array.
Syntax
array.count(items)
Arguments
Returns
Type Description
Examples
l The function array.count($Activity.array) returns 2.
l The function array.count($flow.body.colors) returns 3.
array.create
This function creates an array of primitive types from the specified items. All items must be
of the same primitive types and must match the field type where this function is used. For
example, string, integer.
Syntax
array.create(item1, item2)
Arguments
item1, item2 any Items from which the array needs to be created
Returns
Type Description
array of type any An array of primitive types created from the specified entry.
Examples
The function array.create("A","B","C") returns ["A","B","C"].
array.delete
This function deletes a specific index of an item in the array.
Syntax
array.delete(items, index)
Arguments
items array of type Array from which the specified index of an item needs to be
any deleted
Returns
Type Description
array of type any An array with the specified item deleted from the array.
Examples
The function array.delete(array.create("item1","item2"), 1) returns [item1].
array.flatten
This function creates an array with all the subarray elements concatenated into it
recursively up to the specified depth.
Syntax
array.flatten(items, -1)
Arguments
items array of type any The array that you want to flatten.
depth int The default depth is -1, which indicates no depth limit.
Returns
Type Description
Examples
The function array.flatten(array.create(1, 2, array.create(3,4, array.create
(5,6))), -1) returns [1,2,3,4,5,6].
array.forEach
Using this function, you can iterate over a source array and filter the array elements based
on a condition. If you do not provide any arguments, you can also create a single-item
array.
Important: See the Mapping Complex Arrays for a detailed explanation of using
the array.forEach() function.
Syntax
Arguments
If you do not provide any arguments, you can create a single-item array.
scopeName Scope for your mapping. Each scope has a name to it. By default,
the scope name is the same as the name of the source array.
To use data:
l To use parent data in the child array mappings, provide a
scope name as a second argument in the corresponding
parent array.forEach mapping and then use $loop
[PARENT_SCOPE_NAME].<DATA_ATTRIBUTE> to access the
corresponding data.
l To use data from the current array, use $loop.<DATA_
ATTRIBUTE>.
Returns
Type Description
Examples
l array.forEach($flow.parameters.headers) returns array
array.get
This function gets an item, specified by its index, from an array.
Syntax
array.get(items, index)
Arguments
Returns
Type Description
Examples
The function array.get(array.create("item1","item2"), 1) returns item2.
array.merge
This function merges multiple arrays into one.
Syntax
array.merge(items1, items2…)
Arguments
Returns
Type Description
Examples
The function array.merge(array.create(1,2), array.create(3,4)) returns [1,2,3,4].
array.reverse
This function reverses array elements.
Syntax
array.reverse(items)
Arguments
Returns
Type Description
Examples
The function array.reverse(array.create(1,2)) returns [2,1].
array.slice
This function extracts a part an array by specifying a half-open range with start index and
an end index (the element at the end index is excluded).
Syntax
Arguments
start int The start index/position from which you want to extract the
items from the input array.
end int The end index/position up to which you want the items to be
extracted from the input array.
Returns
Type Description
array of type any The extracted array with elements between the start and end position
Examples
The function array.slice(array.create(1,2,3,4,5), 1, 3) returns [2,3].
array.sum
This function sums all element of a number array.
Syntax
array.sum(items)
Arguments
items Array of type number Input array with elements of number type.
Returns
Type Description
Examples
The function array.sum(array.create(1,2)) returns 3.
Boolean Functions
This section provides a quick reference to the Flogo boolean functions.
boolean.false
This function always returns false.
Syntax
boolean.false()
Arguments
None
Returns
Type Description
Examples
The function boolean.false() returns false.
boolean.not
This function returns the reverse value of a boolean.
Syntax
boolean.not(bool)
Arguments
Bool boolean Boolean for which the reverse value needs to be returned.
Returns
Type Description
Examples
The function boolean.not(boolean.true()) returns false.
boolean.true
This function always returns true.
Syntax
boolean.true()
Arguments
None
Returns
Type Description
Examples
The function boolean.true() returns true.
Coerce Functions
This section provides a quick reference to the Flogo coerce functions.
coerce.toArray
This function converts the specified value to an array.
Syntax
coerce.toArray(value)
Arguments
Returns
Type Description
Examples
The function coerce.toArray($Activity[xxx].xxx) returns a JSON array.
coerce.toBool
This function converts the specified value to a boolean.
Syntax
coerce.toBool(value)
Arguments
Returns
Type Description
Examples
The function coerce.toBool("true") returns true.
coerce.toBytes
This function converts the specified value to bytes.
Syntax
coerce.toBytes(value)
Arguments
Returns
Type Description
Examples
The function coerce.toBytes("hello") returns byte data.
Coerce.toFloat32
This function converts the specified value to float32.
Syntax
coerce.toFloat32(value)
Arguments
Returns
Type Description
Examples
The function coerce.toFloat32("3.3") returns 3.3.
Coerce.toFloat64
This function converts the specified value to float64.
Syntax
coerce.toFloat64(value)
Arguments
Returns
Type Description
Examples
The function coerce.toFloat64("3.3") returns 3.3.
coerce.toInt
This function converts the specified value to an int.
Syntax
coerce.toInt(value)
Arguments
Returns
Type Description
Examples
The function coerce.toInt("333") returns 333.
Coerce.toInt32
This function converts the specified value to an int32.
Syntax
coerce.toInt32(value)
Arguments
Returns
Type Description
Examples
The function coerce.toInt32("333") returns 333.
Coerce.toInt64
This function converts the specified value to int64.
Syntax
coerce.toInt64(value)
Arguments
Returns
Type Description
Examples
The function coerce.toInt64("333") returns 333.
coerce.toObject
This function converts the specified value to an object type.
Syntax
coerce.toObject(value)
Arguments
Returns
Type Description
Examples
The function coerce.toObject($Activity[xxx].xxx) returns a JSON object.
coerce.toParams
This function converts the specified value to params type.
Syntax
coerce.toParams(value)
Arguments
Returns
Type Description
Examples
The function coerce.toParams($Activity[xxx].xxx) returns a string with the name-value
mapping.
coerce.toString
This function converts the specified value to a string.
Syntax
coerce.toString(value)
Arguments
Returns
Type Description
Examples
The function coerce.toString(123) returns "123".
coerce.toType
This function converts a value to a specified type.
Syntax
coerce.toType(value, type)
Arguments
Returns
Type Description
Examples
The function coerce.toType("123","int") returns 123.
Compression Functions
This section provides a quick reference to the following compression functions:
l compression.gzipCompress
l compression.gzipUncompress
compression.gzipCompress
This function takes a string (stringified JSON/XML, base64 encoded binary) as an input and
returns a compressed string using the GZip compression algorithm.
Syntax
compression.gzipCompress (str)
Arguments
Returns
Type Description
Examples
compression.gzipCompress("Hello World").
compression.gzipUncompress
This function takes a GZip compressed string as input and returns a decompressed string
using the GZip decompression algorithm.
Syntax
Arguments
Returns
Type Description
Examples
compression.gzipUncompress("GZipCompressedString")
Data Functions
This section provides a quick reference to the Flogo data functions.
data.GetValue
This function returns the value from the mapping reference. If it is not defined, it returns
the default value specified by the user.
Syntax
data.GetValue(mappingReference, default)
Arguments
default Any The default value specified by the user. If the mapping
reference is not defined, this default value is returned.
Returns
Type Description
Examples
l If $Activity[foo].book[2].price is equal to 30, the function GetValue($Activity
[foo].book[2].price, 90) returns 30.
data.isDefined
This function checks whether the specified mapping reference is defined or not.
Syntax
data.isDefined(mappingReference)
Arguments
Returns
Type Description
Examples
l If $Activity[foo].book[2].price is equal to 30, the function isDefined($Activity
Datetime Functions
This section provides a quick reference to the Flogo datetime functions.
datetime.add
This function adds the specified number of years, months, and days to the specified
datetime.
Syntax
datetime.add(datetime, 0, 0, 0)
Arguments
Returns
Type Description
datetime Date and time after adding the specified number of years, months, and days.
Examples
l The function datetime.add(datetime.current(),0,0,5) returns the date and time
of 5 days later.
l The function datetime.add(datetime.current(), 1, 0, 0) returns the date and
time 1 year from the current date and time such as 2023-05-
11T15:38:55.34586567Z.
datetime.addHours
This function adds the specified number of hours to the mentioned datetime.
Syntax
datetime.addHours(datetime, 0)
Arguments
Returns
Type Description
datetime Date and time after adding the specified number of hours.
Examples
The function datetime.addHours(datetime.current(), 3) returns the date and time of 3
hours later.
datetime.addMins
This function adds the specified number of minutes to the mentioned datetime.
Syntax
datetime.addMins(datetime, 0)
Arguments
The default is 0.
Returns
Type Description
Examples
The function datetime.addMins(datetime.current(), 30) returns the date and time of
30 minutes later.
datetime.addSeconds
This function adds the specified number of seconds to the mentioned datetime.
Syntax
datetime.addSeconds(datetime, 0)
Arguments
datetime datetime Date and time to which the seconds need to be added.
Returns
Type Description
Examples
The function datetime.addSeconds(datetime.current(), 30) returns the date and time
of 30 seconds later.
datetime.create
This function creates a date by using the specified details. The details such as year,
months, days, hours, minutes, seconds, nanoseconds, and timezone. The timezone follows
the IANA time zone.
Syntax
datetime.create(0, 0, 0, 0, 0, 0, 0, UTC)
Arguments
Returns
Type Description
datetime A date created by using the specified details. The details such as year, months,
days, hours, mins, seconds, nanoseconds, and timezone.
Examples
The function datetime.create(2020,1,3,2,22,0,0, "America/Los_Angeles") returns
2020-01-03T02:22:00-08:00.
datetime.current
This function returns the current datetime in the UTC timezone.
Syntax
datetime.current()
Arguments
None
Returns
Type Description
Examples
The function datetime.current() returns the current date and time.
datetime.currentDate
This function returns the current date in the UTC time zone.
Syntax
datetime.currentDate()
Arguments
None.
Returns
Type Description
Examples
The function datetime.currentDate() returns the current date in the UTC time zone.
datetime.currentDatetime
This function returns the current datetime in the UTC timezone.
Syntax
datetime.currentDatetime()
Arguments
None
Returns
Type Description
Examples
The function datetime.currentDatetime() returns the current datetime in the UTC
timezone.
datetime.currentTime
This function returns the current time in the UTC timezone.
Syntax
datetime.currentTime()
Arguments
None
Returns
Type Description
Examples
The function datetime.currentTime() returns the current time in the UTC timezone.
datetime.diff
This function returns the difference between two specified datetime values.
Syntax
Arguments
Returns
Type Description
Examples
The function datetime.diff(datetime.current(), datetime.addHours
(datetime.current(), 2), "hours") returns 2.
datetime.format
This function displays the date according to the specified format. The format uses MM
(month), DD(day), YYYY(year), hh(hour), mm(minute), and ss(second). Except MM, the rests
are not case-sensitive. The datetime format can also be set with a following predefined
layout:
l ANSIC
l Unix Date
l RubyDate
l RFC822
l RFC822Z
l RFC850
l RFC1123
l RFC1123Z
l RFC3339,
l RFC3339Nano
Syntax
datetime.format(datetime, format)
Arguments
Returns
Type Description
Examples
The function datetime.format(datetime.current(), "RFC3339") returns the current date
and time in RFC3339 format.
datetime.formatDate
This function displays the date according to the specified format. The format uses MM
(month), DD(day), and YYYY(year) and they are not case-sensitive.
Syntax
datetime.formatDate(date, format)
Arguments
Returns
Type Description
Examples
The function datetime.formatDate("02/08/2017", "dd-MM-yyyy") returns 08-02-2017.
datetime.formatDatetime
This function displays the date and time according to the specified format. The format uses
MM(month), DD(day), YYYY(year), hh(hour), mm(minute), and ss(second). Except for MM, the
others are not case-sensitive.
Syntax
datetime.formatDatetime(datetime, format)
Arguments
Returns
Type Description
Examples
The function datetime.formatDatetime("2017-04-10T22:17:32.000+0700", "dd/MM/yyyy
T hh:mm:ss") returns 10/04/2017 T 22:17:32.
datetime.formatTime
This function formats the time according to the specified format. The format uses hh(hour),
mm(minute), ss(second), and is not case-sensitive.
Syntax
datetime.formatTime(datetime, format)
Arguments
Returns
Type Description
Examples
The function datetime.formatTime("10:11:05.00000", "hh-mm-ss") returns 10-11-05.
datetime.now
This function returns the current date and time in the UTC timezone.
Syntax
datetime.now()
Arguments
None
Returns
Type Description
Examples
The function datetime.now() returns something like 2020-03-19T15:02:03+06:00.
datetime.parse
This function parses the given datetime to the DateTime with time zone, default base on
UTC. The timezone follows the IANA timezone.
Syntax
datetime.parse(str, UTC)
Arguments
Returns
Type Description
Examples
The function datetime.parse("2020-03-19T15:02:03+06:00", "America/Los_Angeles")
returns 2020-03-19T02:02:03-07:00.
Datetime.sub
This function subtracts the given number of years, months, or days from the datetime.
Syntax
datetime.sub(datetime, 0, 0, 0)
Arguments
Returns
Type Description
datetime Date and time after subtracting the specified years, months, and days.
Examples
The function datetime.sub(datetime.current(), 1,1,1) returns the date and time of 1
year, 1 month, and 1 day ago.
datetime.subHours
This function subtracts the given number of hours from the DateTime.
Syntax
datetime.subHours(datetime, hours)
Arguments
Returns
Type Description
Examples
The function datetime.subHours(datetime.current(),1) returns the date and time of 1
hour ago.
datetime.subMins
This function subtracts the given number of minutes from the datetime.
Syntax
datetime.subMins(datetime, mins)
Arguments
Default is 0.
Returns
Type Description
Examples
The function datetime.subMins(datetime.current(),10) returns the date and time 10
minutes ago.
Datetime.subSeconds
This function subtracts the given number of seconds from the datetime.
Syntax
datetime.subSeconds(datetime, seconds)
Arguments
Returns
Type Description
Examples
The function datetime.subSeconds(datetime.current(),10) returns what the date and
time was 10 seconds ago.
Float Functions
This section provides a quick reference to the Flogo float functions.
float.float64
This function converts the input to a float64 with the specified (optional) floating point
precision.
Syntax
float.float64(input, 16)
Arguments
precision int (Optional) The default precision value is 16. Any precision value
greater than 16, defaults to 16.
Returns
Type Description
Examples
The function float.float64("2.77876542316664548335",14) returns 2.77876542316664.
JSON Functions
This section provides a quick reference to the Flogo JSON functions.
json.exists
This function checks whether the key or JSONPath is present in the JSON object. For the
expression format, see https://github.com/oliveagle/jsonpath.
Syntax
json.exists(jsonObject, key)
Arguments
Returns
Type Description
boolean True, if the value is associated with the key or JSONPath. False otherwise.
Examples
Let us say the jsonObject includes the following.
jsonObject =
{
"colors":
[
{ "id": 1, "value": "red" },
{ "id": 2, "value": "green" },
{ "id": 3, "value": "blue" }
]
}
In this case:
l The function json.exists(jsonObject, "$loop.colors[?(@.value ==
'red')].value[0]") returns true.
json.get
This function gets the value of the associated key from the JSON object.
Syntax
json.get(jsonObject, key)
Arguments
Returns
Type Description
Examples
Let us say the jsonObject includes the following.
jsonObject = {
"id": 1,
"name": "bob"
}
json.length
This function gets the number of top-level elements in the JSON object or array.
Syntax
json.length(jsonObjectOrArray)
Arguments
Returns
Type Description
Examples
Let us say the jsonObject includes the following.
jsonObject = {
"id": 1,
"name": "bob"
}
json.numbersToString
This function converts every number type to string in a JSON object or array.
Syntax
json.numbersToString(jsonObjectOrArray)
Arguments
Returns
Type Description
Examples
Let us say the jsonObject includes the following:
jsonObject = {
"id": 1,
"name": "bob"
}
{
"id": "1",
"name": "bob"
}
json.objKeys
This function gets the list of all top-level keys of a JSON object.
Syntax
json.objKeys(jsonObject)
Arguments
Returns
Type Description
Examples
Let us say the jsonObject includes the following.
jsonObject = {
"id": 1,
"name": "bob"
}
json.objValues
This function gets the list of all top-level values of a JSON object.
Syntax
json.objValues(jsonObject)
Arguments
Returns
Type Description
Examples
Let us say the jsonObject includes the following:
jsonObject = {
"id": 1,
"name": "bob"
}
json.path
Using this function you can query an element within JSON data. In order to reach the
desired node or a specific field in the node in the JSON data, you must follow a specific
notation defined in the JsonPath specification. See https://jqlang.github.io/jq/manual/ for
details on the notation to be used and specific examples of using the notation.
Important: See the Mapping JSON Data with the json.path() Function for a
detailed explanation on using the json.path() function.
Syntax
json.path(path, object)
Arguments
path string The search path to the element within the JSON data.
object any The JSON object that contains the JSON data you are searching.
Returns
Type Description
Examples
Let us say the jsonObject includes the following:
jsonObject = {
"colors": [
{ "id": 1, "value": "red" },
{ "id": 2, "value": "green" },
{ "id": 3, "value": "blue" }
]
}
json.jq
This function applies a query to the parsed JSON object and returns a filtered array. For
more information, see https://jqlang.github.io/jq/manual/.
Syntax
json.jq(JSONobject, "query")
Arguments
query string The query using which the JSON object is filtered.
Returns
Type Description
Examples
Let us say the jsonObject includes the following:
jsonObject =
{
"colors":
[
{ "id": 1, "value": "red" },
{ "id": 2, "value": "green" },
{ "id": 3, "value": "blue" }
]
}
json.set
This function sets the value of the existing key or add new key and set its value in a JSON
object.
Syntax
Arguments
Returns
Type Description
Examples
Let us say the jsonObject includes the following:
jsonObject = {
"colors": [
{
"colors": [
{ "id": 1, "value": "red" },
{ "id": 2, "value": "green" },
{ "id": 3, "value": "blue" }
],
"timestamp": 1652187627
}
Math Functions
This section provides a quick reference to the Flogo math functions.
math.ceil
This function returns the least integer value greater than or equal to the input.
Syntax
math.ceil(inputNumber)
Arguments
Returns
Type Description
Examples
The function math.ceil(1.49) returns 2.
math.floor
This function returns the greatest integer value less than or equal to the input.
Syntax
math.floor(inputNumber)
Arguments
Returns
Type Description
Examples
The function math.floor(1.51) returns 1.
math.isNaN
This function reports whether the input is an IEEE 754 "not-a-number" value.
Syntax
math.isNaN(input)
Arguments
Returns
Type Description
Examples
The function math.isNaN(1.0) returns false.
math.mod
This function returns the floating-point remainder of x/y. The magnitude of the result is
less than y and its sign agrees with that of x.
Syntax
math.mod(x, y)
Arguments
Returns
Type Description
Examples
The function math.mod(7, 4) returns 3.0.
math.round
This function returns the nearest integer, rounding half away from zero.
Syntax
math.round(inputNumber)
Arguments
Returns
Type Description
Examples
The function math.round(1.50) returns 2.0.
math.roundToEven
This function returns the nearest integer, rounding ties to even.
Syntax
math.roundToEven(inputNumber)
Arguments
Returns
Type Description
Examples
The function math.roundtoeven(12.5) returns 12.0.
math.trunc
This function returns the integer value of the input.
Syntax
math.trunc(inputNumber)
Arguments
Returns
Type Description
Examples
The function math.trunc(3.142) returns 3.0.
Number Functions
This section provides a quick reference to the Flogo number functions.
number.int64
This function converts the input to an integer.
Syntax
number.int64(input)
Arguments
Returns
Type Description
Examples
The function number.int64("123") returns 123.
number.len
This function returns the length of a string.
Syntax
number.len(input)
Arguments
Returns
Type Description
Examples
The function number.len("123") returns 3.
number.random
This function generates a random number.
Syntax
number.random(limit)
Arguments
Returns
Type Description
Examples
The function number.random(100) returns 90.
String Functions
This section provides a quick reference to the Flogo string functions.
String.base64ToString
This function decodes a base64-encoded string and returns the decoded string.
Syntax
string.base64ToString(base64str)
Arguments
Returns
Type Description
Examples
The function string.base64ToString("SGVsbG8sIFdvcmxk") returns a string like Hello,
World.
string.concat
This function concatenates a set of strings.
Syntax
string.concat(str1, str2)
Arguments
Returns
Type Description
Examples
The function string.concat("Hello",' ', "World") returns Hello World.
string.contains
This function checks whether a specified string exists within another string.
Syntax
string.contains(str1, str2)
Arguments
Returns
Type Description
Examples
The function string.contains("foobar","foo") returns true.
string.containsAny
This function reports whether any Unicode code points in characters exist within the input
settings.
Syntax
string.containsAny(str, substr)
Arguments
Returns
Type Description
Examples
The function string.containsAny("Seafood", "food") returns true.
string.count
This function counts the number of non-overlapping instances of a substring in the input
string.
Syntax
string.count(str, substr)
Arguments
substr string Substring whose instances need to be searched for in the source
string
Returns
Type Description
Examples
The function string.count("hello flogo", "o") returns 3.
string.dateFormat
This function returns a default date format.
Syntax
string.dateFormat()
Arguments
None
Returns
Type Description
string "YYYY-MM-DD"
Examples
The function string.dateFormat() returns 2006-01-02-07:00.
string.lastIndex
This function returns the index of the last instance of substring in the specified input string.
Syntax
string.lastIndex(str, substr)
Arguments
substr string Substring for which the index of the last instance needs to be
searched.
Returns
Type Description
Examples
The function string.lastIndex("hello flogo", "flogo") returns 6.
string.datetimeFormat
This function returns a default datetime format.
Syntax
string.datetimeFormat()
Arguments
None
Returns
Type Description
string “YYYY-MM-DDTHH:mm:ss”
Examples
The function string.datetimeFormat() returns 2006-01-02T15:04:05-07:00.
string.endsWith
This function indicates whether a string ends with another string.
Syntax
string.endsWith(str, substr)
Arguments
Returns
Type Description
Examples
The function string.endsWith("This is a project created in Flogo", "Flogo")
returns true.
string.equals
This function checks whether two strings are equal.
Syntax
string.equals(str1, str2)
Arguments
Returns
Type Description
Examples
The function string.equals("Hello","Hello2") returns false.
string.equalsIgnoreCase
This function checks whether two strings are equal, ignoring the case.
Syntax
string.equalsIgnoreCase(str1, str2)
Arguments
Returns
Type Description
Examples
The function string.equalsIgnoreCase("Hello","hello") returns true.
string.float
This function converts the string to a float.
Syntax
string.float(str1, precision)
Arguments
Returns
Type Description
Examples
The function string.float("2.77876542316664548335",14) returns 2.77876542316665.
string.index
This function returns the index of the first instance of a substring in the input string.
Syntax
string.index(str, substr)
Arguments
Returns
Type Description
Examples
The function string.index("hello flogo", "flogo") returns 6.
string.indexAny
In the input string, this function returns the index of the first instance of any Unicode code
point form characters.
Syntax
string.indexAny(str, substr)
Arguments
Returns
Type Description
int -1: if no Unicode code point form characters are present in the input string
Examples
The function string.indexAny("hello flogo", "flogo") returns 2.
string.integer
This function converts the string to an integer.
Syntax
string.integer(str1)
Arguments
Returns
Type Description
Examples
The function string.integer("1001") returns 1001.
string.join
This function converts an array to its string representation and concatenates its elements
using the specified separator between each element.
Syntax
string.join(items, separator)
Arguments
Returns
Type Description
string Concatenated string representation of the array with the specified separator
between each array element.
Examples
The function string.join(array.create("a", "b"), "-") returns a-b.
string.len
This function gets the length of a string.
Syntax
string.len(str1)
Arguments
Returns
Type Description
Examples
The function string.len("hello") returns 5.
string.length
This function returns the length of a string.
Syntax
string.length("str")
Arguments
Returns
Type Description
Examples
The function string.length("FLOGO") returns 5.
string.lowerCase
This function returns the string in lowercase.
Syntax
string.lowerCase(str)
Arguments
Returns
Type Description
Examples
The function string.lowerCase("FLOGO") returns flogo.
string.matchRegEx
This function matches the input against a regular expression.
Syntax
string.matchRegEx(expression, str)
Arguments
expression string Regular expression against which the source string needs to be
matched.
Returns
Type Description
Examples
The function string.matchRegEx("foo.*", "seafood") returns true.
string.regex
This function checks whether a regular expression pattern matches a string.
Syntax
string.regex(pattern, str)
Arguments
pattern string Regular expression pattern against which the source string needs
to be matched.
Returns
Type Description
boolean l True: if the source string matches the regular expression pattern
l False: if the source string does not match the regular expression
pattern
Examples
The function string.regex("foo.*", "seafood") returns true.
string.repeat
This function returns a new string consisting of <count> copies of the specified string.
Syntax
string.repeat(str, count)
Arguments
count int Number that indicates how many times the string needs to be
repeated
Returns
Type Description
Examples
The function string.repeat("hello flogo", 2) returns hello flogo hello flogo.
string.replace
This function returns a copy of the input string where <count> non-overlapping instances
of <old> are replaced by <new>.
Syntax
Arguments
Returns
Type Description
Examples
The function string.replace("hello flogo", "flogo", "world", -1) returns hello
world.
string.replaceAll
This function returns a copy of the input string with all non-overlapping <old> instances
are replaced by <new>.
Syntax
Arguments
Returns
Type Description
Examples
The function string.replaceAll("hello flogo", "flogo", "world") returns hello
world.
string.replaceRegEx
This function replaces data in a string based on a regular expression match.
Syntax
Arguments
expression string Characters from the source string are replaced based on the
regular expression match.
Returns
Type Description
string New string, where characters matching the regular expression are replaced with
the <replace> string
Examples
The function string.replaceRegEx("foo.*", "seafood", "People") returns seaPeople.
string.split
This function slices a string into all substrings separated by <sep> and returns a slice of the
substrings between those separators.
Syntax
string.split(str, separator)
Arguments
Returns
Type Description
Examples
The function string.split("Hello,World", ",") returns [Hello,World].
string.startsWith
This function returns whether a string begins with another string.
Syntax
string.startsWith(str, substr)
Arguments
Returns
Type Description
Examples
The function string.startsWith("Project Flogo™", "Project") returns true.
String.stringToBase64
This function returns a base64-encoded version of the input string.
Syntax
string.stringToBase64(str)
Arguments
Returns
Type Description
Examples
The function string.stringToBase64("Hello, World") returns SGVsbG8sIFdvcmxk.
string.substring
This function gets a substring from a string.
Syntax
Arguments
Returns
Type Description
Examples
The function string.substring("abc", 1,1) returns b.
string.substringAfter
This function returns the string that follows the first occurrence of the second argument.
Syntax
string.substringAfter(str, afterstr)
Arguments
afterstr string Characters after the first occurrence of this string need to be
returned
Returns
Type Description
string l String that follows after the first occurrence of the second string.
l Zero length string if the first string does not contain the second
string.
Examples
The function string.substringAfter("1999/04/01", "/") returns 04/01.
string.substringBefore
This function returns the string that appears before the first occurrence of the second
string.
Syntax
string.substringBefore(str, beforestr)
Arguments
beforestr string Characters before the first occurrence of this string need to
be returned
Returns
Type Description
string l String that appears before the first occurrence of the second
string.
l Zero length string if the first string does not contain the second
string.
Examples
The function string.substringBefore("1999/04/01", "/") returns 1999.
string.timeFormat
This function returns a default time format.
Syntax
string.timeFormat()
Arguments
None
Returns
Type Description
Examples
The function string.timeFormat() returns 15:04:05-07:00.
string.toLower
This function returns a copy of input string with all Unicode letters mapped to their lower
case.
Syntax
string.toLower(str)
Arguments
Returns
Type Description
Examples
The function string.toLower("Hello World") returns hello world.
string.toTitleCase
This function returns a string after capitalizing the first letter of every word.
Syntax
string.toTitleCase(str)
Arguments
Returns
Type Description
Examples
The function string.toTitleCase("hello world") returns Hello World.
string.toUpper
This function returns a copy of input string with all Unicode letters mapped to their upper
case.
Syntax
string.toUpper(str)
Arguments
Returns
Type Description
Examples
The function string.toUpper("Hello World") returns HELLO WORLD.
string.tostring
This function converts an object to a string.
Syntax
string.tostring(input)
Arguments
Returns
Type Description
Examples
The function string.tostring(123) returns "123".
string.trim
This function returns a part of the input string with all leading and trailing Unicode code
points contained in the cutset removed.
Syntax
string.trim(str)
Arguments
Returns
Type Description
string String with all leading and trailing Unicode code points
Examples
l The function tring.trim(" Hello World ", " ") returns Hello World.
l The function string.trim("¡¡¡Hello, Gophers!!!", "!¡") returns Hello Gophers.
string.trimLeft
This function returns a slice of the input string with all the leading Unicode code points
contained in cutset removed from the left.
Syntax
string.trimLeft(str, cutset)
Arguments
cutset string Set of characters that need to be removed from the left
Returns
Type Description
string Slice of the input string with all the leading Unicode code points contained in
cutset removed from the left.
Examples
l The function string.trimLeft(" Hello World ", " ") returns Hello World.
l The function string.trimLeft("¡¡¡Hello, Gophers!!!", "!¡")" returns Hello,
Gophers!!!.
string.trimPrefix
This function returns the input string without the provided leading prefix string. If the input
string does not start with the prefix, it is returned unchanged.
Syntax
string.trimPrefix(str, prefix)
Arguments
Returns
Type Description
Examples
l The function string.trimPrefix("Hello World ", "Hello") returns World.
l The function string.trimPrefix("¡¡¡Hello, Gophers!!!", "¡¡¡Hello,")" returns
Gophers!!!.
string.trimRight
This function returns a slice of the input string with all the trailing Unicode code points
contained in the cutset removed from the right.
Syntax
string.trimRight(str, cutset)
Arguments
Returns
Type Description
string Slice of the source string with all trailing Unicode code points contained in the
cutset removed from the right.
Examples
l The function string.trimRight(" Hello World ", " ") returns Hello World.
l The function string.trimRight("¡¡¡Hello, Gophers!!!", "!¡") returns ¡¡¡Hello,
Gophers.
string.trimSuffix
This function returns the input string without the specified trailing suffix string. If it does
not end with a suffix, it is returned unchanged.
Syntax
string.trimSuffix(str, suffix)
Arguments
Returns
Type Description
Examples
l The function string.trimSuffix("Hello World", "World") returns Hello.
l The function string.trimSuffix("¡¡¡Hello, Gophers!!!", ", Gophers!!!")
returns ¡¡¡Hello.
string.upperCase
This function returns the string in uppercase.
Syntax
string.upperCase(str)
Arguments
Returns
Type Description
Examples
The function string.upperCase("Flogo") returns FLOGO.
URL Functions
This section provides a quick reference to the Flogo URL functions.
url.encode
This function returns the URL encoded form of the input string.
Syntax
url.encode(rawURLString)
Arguments
Returns
Type Description
Examples
The function url.encode("https://subdomain.example.com/path?q=hello
world#fragment with space") returns
https://subdomain.example.com/path?q=hello+world#fragment%20with%20space.
url.escapedPath
This function returns the escaped path part of the URL, removing everything except the
PATH after the hostname.
Syntax
url.escapedPath(rawURLString)
Arguments
Returns
Type Description
Examples
The function url.escapedPath("https://example.com:8080/root-
path/sub%2Fpath?query=example+query+%2F+question#fragment") returns "/root-
path/sub%2Fpath".
url.hostname
This function returns the hostname for the URL, removing any valid port number if present.
If the input is enclosed in square brackets, as literal IPv6 addresses are, the square
brackets are removed from the output.
Syntax
url.hostname(rawURLString)
Arguments
Returns
Type Description
Examples
The function url.hostname("https://example.com:8080/root-path/sub-
path?query=example+query+%2F+question#fragment") returns example.com.
url.path
This function returns the path part of the URL.
Syntax
url.path(rawURLString)
Arguments
Returns
Type Description
Examples
The function url.path("https://example.com:8080/root-path/sub-
path?query=example+query+%2F+question#fragment") returns "/root-path/sub-path".
url.pathEscape
This function returns the escaped string so it can be safely placed inside a URL path
segment, replacing special characters (including /) with %XX sequences as needed.
Syntax
url.pathEscape(pathString)
Arguments
Returns
Type Description
Examples
The function url.pathEscape("/some-path with ([brackets])") returns "%2Fsome-
path%20with%20%28%5Bbrackets%5D%29".
url.port
This function returns the port part of the URL, without the leading colon. If the URL does
not contain a valid numeric port, it returns an empty string.
Syntax
url.port(rawURLString)
Arguments
Returns
Type Description
Examples
The function url.port("https://example.com:8080/root-path/sub-
path?query=example+query+%2F+question#fragment") returns "8080".
url.query
This function returns the encoded query string if the second parameter is set to true. It
returns an object with a key value pair of query and value, if the second parameter is set to
false.
Syntax
url.query(rawURLString, encode)
Arguments
encode boolean Set this argument to true to encode the query string. Set it
to false to get the object.
Returns
Type Description
Examples
The function url.query("https://example.com:8080/root-path/sub-
path?query=example+query+%2F+question#fragment", true) returns
"query=example+query+%2F+question".
url.queryEscape
This function encodes the input string so it can be safely placed inside a URL query. Note
that this function does not create the full query string.
Syntax
url.queryEscape(queryValue)
Arguments
Returns
Type Description
Examples
The function url.queryEscape("hello world") returns hello+world.
url.scheme
This function returns the URL scheme.
Syntax
url.scheme(rawURLString)
Arguments
Returns
Type Description
Examples
The function url.scheme("https://example.com:8080/root-path/sub-
path?query=example+query+%2F+question#fragment") returns https.
Utility Functions
This section provides a quick reference to the Flogo utility functions.
utility.renderJSON
This function converts the provided JSON data to a string. The false argument specifies
whether the JSON data should be converted to an easily readable and neat format.
Syntax
Arguments
Returns
Type Description
Examples
The function utility.renderJSON($RestInvoke.responseBody, false) returns
{"FirstName":"ABC","LastName":"XYZ"}.
Utils Functions
This section provides a quick reference to the Flogo utils functions.
Utils.decodeBase64
This function converts a base64 encoded string into a human-readable format.
Syntax
utils.decodeBase64(<input string>)
Arguments
Returns
Type Description
Examples
The function utils.decodeBase64("SGVsbG8sIFdvcmxk") returns Hello, World.
Utils.encodeBase64
This function converts a string to a Base64 encoded string.
Syntax
utils.encodeBase64(<input string>)
Arguments
Returns
Type Description
Examples
The function utils.encodeBase64(coerce.ToBytes("Hello, World")) returns
SGVsbG8sIFdvcmxk.
utils.uuid
This function generates a random UUID according to the RFC 4122 standard.
Syntax
utils.uuid()
Arguments
None
Returns
Type Description
Examples
The function utils.uuid() returns 245056b5-0d11-47aa-b564-fbbf3c6e044a.
Product-Specific Documentation
The following documentation for this product is available on the TIBCO Flogo® Enterprise
Product Documentation page.
requests from within the TIBCO Ideas Portal. For a free registration, go to
TIBCO Community.
USE OF CLOUD SG SOFTWARE AND CLOUD SERVICES IS SUBJECT TO THE TERMS AND CONDITIONS
OF AN AGREEMENT FOUND IN EITHER A SEPARATELY EXECUTED AGREEMENT, OR, IF THERE IS NO
SUCH SEPARATE AGREEMENT, THE CLICKWRAP END USER AGREEMENT WHICH IS DISPLAYED WHEN
ACCESSING, DOWNLOADING, OR INSTALLING THE SOFTWARE OR CLOUD SERVICES (AND WHICH IS
DUPLICATED IN THE LICENSE FILE) OR IF THERE IS NO SUCH LICENSE AGREEMENT OR CLICKWRAP
END USER AGREEMENT, THE LICENSE(S) LOCATED IN THE “LICENSE” FILE(S) OF THE SOFTWARE. USE
OF THIS DOCUMENT IS SUBJECT TO THOSE SAME TERMS AND CONDITIONS, AND YOUR USE HEREOF
SHALL CONSTITUTE ACCEPTANCE OF AND AN AGREEMENT TO BE BOUND BY THE SAME.
This document is subject to U.S. and international copyright laws and treaties. No part of this
document may be reproduced in any form without the written authorization of Cloud Software
Group, Inc.
TIBCO, the TIBCO logo, the TIBCO O logo, and Flogo are either registered trademarks or trademarks
of Cloud Software Group, Inc. in the United States and/or other countries.
All other product and company names and marks mentioned in this document are the property of
their respective owners and are mentioned for identification purposes only. You acknowledge that all
rights to these third party marks are the exclusive property of their respective owners. Please refer to
Cloud SG’s Third Party Trademark Notices (https://www.cloud.com/legal) for more information.
This document includes fonts that are licensed under the SIL Open Font License, Version 1.1, which is
available at: https://scripts.sil.org/OFL
Copyright (c) Paul D. Hunt, with Reserved Font Name Source Sans Pro and Source Code Pro.
Cloud SG software may be available on multiple operating systems. However, not all operating
system platforms for a specific software version are released at the same time. See the “readme” file
for the availability of a specific version of Cloud SG software on a specific operating system platform.
THIS DOCUMENT IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
This and other products of Cloud SG may be covered by registered patents. For details, please refer
to the Virtual Patent Marking document located at https://www.cloud.com/legal.