Functions from E - H

empty

Check whether an instance is empty. Return true if the input is empty. Empty means:

  • input is null or undefined
  • input is a null or empty string
  • input is zero size collection
  • input is an object with no property.
empty('<instance>')
empty([<instance>])

ParameterRequiredTypeDescription
<instance>YesanyThe instance to check
Return valueTypeDescription
true or falseBooleanReturn true when the instance is empty.

Example

These examples check whether the specified instance is empty:

empty('')
empty('abc')
empty([1])
empty(null)

And return these results respectively:

  • Passes an empty string, so the function returns true.
  • Passes the string abc, so the function returns false.
  • Passes the collection with one item, so the function returns false.
  • Passes the null object, so the function returns true.

endsWith

Check whether a string ends with a specific substring. Return true if the substring is found, or return false if not found. This function is case-insensitive.

endsWith('<text>', '<searchText>')

ParameterRequiredTypeDescription
<text>YesstringThe string to check
<searchText>YesstringThe ending substring to find
Return valueTypeDescription
true or falseBooleanReturn true when the ending substring is found. Return false if not found

Example 1

This example checks whether the hello world string ends with the string world:

endsWith('hello world', 'world')

And it returns the result true.

Example 2

This example checks whether the hello world string ends with the string universe:

endsWith('hello world', 'universe')

And it returns the result false.

EOL

Return the end of line (EOL) sequence text.

EOL()

Return valueTypeDescription
<IsOSPlatform>stringReturn \r\n in Windows and \n in Mac and Linux.

Example

This example checks the end of the line sequence text:

EOL()

And returns the following strings:

  • Windows: \r\n
  • Mac or Linux: \n

equals

Check whether both values, expressions, or objects are equivalent. Return true if both are equivalent, or return false if they're not equivalent.

equals('<object1>', '<object2>')

ParameterRequiredTypeDescription
<object1>, <object2>YesanyThe values, expressions, or objects to compare
Return valueTypeDescription
true or falseBooleanReturn true when both are equivalent. Return false if not equivalent.

Example

These examples check whether the specified inputs are equivalent:

equals(true, 1)
equals('abc', 'abcd')

And returns these results respectively:

  • Both values are equivalent, so the function returns true.
  • Both values aren't equivalent, so the function returns false.

exists

Evaluates an expression for truthiness.

exists(expression)

ParameterRequiredTypeDescription
expressionYesexpressionExpression to evaluate for truthiness
Return valueTypeDescription
<true or false>BooleanResult of evaluating the expression

Example

These example evaluate the truthiness of foo = {"bar":"value"}:

exists(foo.bar)
exists(foo.bar2)

And return these results respectively:

  • true
  • false

exp

Return exponentiation of one number to another.

exp(realNumber, exponentNumber)

ParameterRequiredTypeDescription
realNumberYesnumberReal number to compute exponent of
exponentNumberYesnumberExponent number
Return valueTypeDescription
<result-exp>numberThe result from computing exponent of realNumber

Example

This example computes the exponent:

exp(2, 2)

And returns the result 4.

first

Return the first item from a string or array.

first('<collection>')
first([<collection>])

ParameterRequiredTypeDescription
<collection>Yesstring or arrayThe collection in which to find the first item
Return valueTypeDescription
<first-collection-item>anyThe first item in the collection

Example

These examples find the first item in the following collections:

first('hello')
first(createArray(0, 1, 2))

And return these results respectively:

  • h
  • 0

flatten

Flatten an array into non-array values. You can optionally set the maximum depth to flatten to.

flatten([<collection>], '<depth>')

ParameterRequiredTypeDescription
<collection>YesarrayThe collection to flatten
<depth>NonumberMaximum depth to flatten. Default is infinity.
Return valueTypeDescription
<new-collection>arrayNew collection whose elements have been flattened to a non-array to the specified depth.

Example 1

THis example flattens the following array:

flatten(createArray(1, createArray(2), createArray(createArray(3, 4), createArray(5, 6)))

And returns the result [1, 2, 3, 4, 5, 6].

Example 2

This example flattens the array to a depth of 1:

flatten(createArray(1, createArray(2), createArray(createArray(3, 4), createArray(5, 6)), 1)

And returns the result [1, 2, [3, 4], [5, 6]].

float

Convert the string version of a floating-point number to a floating-point number. You can use this function only when passing custom parameters to an app, such as a logic app. An exception will be thrown if the string can't be converted to a float.

float('<value>')

ParameterRequiredTypeDescription
<value>YesstringThe string that has a valid floating-point number to convert to
Return valueTypeDescription
<float-value>floatThe floating-point number of the specified string

Example

This example converts the float version of a string:

float('10.333')

And returns the float 10.333.

floor

Return the largest integral value less than or equal to the specified number.

floor('<number>')

ParameterRequiredTypeDescription
<number>YesnumberAn input number
Return valueTypeDescription
<integer-value>integerThe largest integral value less than or equal to the input number

Example

This example calculates the floor value of the number 10.333:

floor(10.333)

And returns the integer 10.

foreach

Operate on each element and return the new collection.

foreach([<collection/instance>], <iteratorName>, <function>)

ParameterRequiredTypeDescription
<collection/instance>Yesarray or objectThe collection with the items
<iteratorName>Yesiterator nameThe key item of arrow function
<function>YesexpressionFunction that contains iteratorName
Return valueTypeDescription
<new-collection>arrayThe new collection in which each element has been evaluated by the function.

Example 1

This example generates a new collection:

foreach(createArray(0, 1, 2, 3), x, x + 1)

And returns the result [1, 2, 3, 4].

Example 2

These examples generate a new collection:

foreach(json("{'name': 'jack', 'age': '15'}"), x, concat(x.key, ':', x.value))
foreach(json("{'name': 'jack', 'age': '15'}"), x=> concat(x.key, ':', x.value))

And return the result ['name:jack', 'age:15']. Note that the second expression is a lambda expression, which some find more readable.

formatDateTime

Return a timestamp in an optional locale format.

formatDateTime('<timestamp>', '<format>'?, '<locale>'?)

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
<format>NostringA custom format pattern. Default: UTC ISO format YYYY-MM-DDTHH:mm:ss.fffZ, which complies with ISO 8601.
<locale>NostringAn optional locale of culture information
Return valueTypeDescription
<reformatted-timestamp>stringThe updated timestamp in the specified format

Example 1

This example converts a timestamp to the specified format:

formatDateTime('03/15/2018 12:00:00', 'yyyy-MM-ddTHH:mm:ss')

And returns the result 2018-03-15T12:00:00.

Example 2

This example converts a timestamp in the de-DE locale:

formatDateTime('2018-03-15', '', 'de-DE')

And returns the result 15.03.18 00:00:00.

formatEpoch

Return a timestamp in an optional locale format in the specified format from UNIX time (also know as Epoch time, POSIX time, UNIX Epoch time).

formatEpoch('<epoch>', '<format>'?, '<locale>'?)

ParameterRequiredTypeDescription
<epoch>YesnumberThe epoch number
<format>NostringA custom format pattern. Default: UTC ISO format YYYY-MM-DDTHH:mm:ss.fffZ, which complies with ISO 8601.
<locale>NostringAn optional locale of culture information
Return valueTypeDescription
<reformatted-timestamp>stringThe updated timestamp in the specified format

Example

This example converts a Unix timestamp to the specified format:

formatEpoch(1521118800, 'yyyy-MM-ddTHH:mm:ss.fffZ)'

And returns the result 2018-03-15T12:00:00.000Z.

Example

This example converts a Unix timestamp in the de-DE locale:

formatEpoch(1521118800, '', 'de-DE')

And returns the result 15.03.18 13:00:00.

formatNumber

Format a value to the specified number of fractional digits and an optional specified locale.

formatNumber('<number>', '<precision-digits>', '<locale>'?)

ParameterRequiredTypeDescription
<number>YesnumberAn input number
<precision-digits>YesintegerA specified number of fractional digits
<locale>NostringAn optional locale of culture information
Return valueTypeDescription
<return-value>numberThe return value of the input formatted at a specified number of fractional digits and a specified locale.

Example 1

This example formats the number 10.333 to 2 fractional digits:

formatNumber(10.333, 2)

And returns the string 10.33.

Example 2

These examples format numbers to a specified number of digits in the en-US locale:

formatNumber(12.123, 2, 'en-US')
formatNumber(1.551, 2, 'en-US')
formatNumber(12.123, 4, 'en-US')

And return the following results respectively:

  • 12.12
  • 1.55
  • 12.1230

formatTicks

Return a timestamp in an optional locale format in the specified format from ticks.

formatTicks('<ticks>', '<format>'?, '<locale>'?)

ParameterRequiredTypeDescription
<epoch>Yesnumber (or bigint in JavaScript)The ticks number
<format>NostringA custom format pattern. Default: UTC ISO format YYYY-MM-DDTHH:mm:ss.fffZ, which complies with ISO 8601.
<locale>NostringAn optional locale of culture information
Return valueTypeDescription
<reformatted-timestamp>stringThe updated timestamp in the specified format

Example 1

This example converts ticks to the specified format:

formatTicks(637243624200000000, 'yyyy-MM-ddTHH:mm:ss.fffZ')

And returns the result 2020-05-06T11:47:00.000Z.

Example 2

This example converts ticks to the specified format in the de-DE locale:

formatTicks(637243624200000000, '', 'de-DE')

And returns the result 06.05.20 11:47:00.

getFutureTime

Return the current timestamp in an optional locale format plus the specified time units.

getFutureTime(<interval>, <timeUnit>, '<format>'?, '<locale>'?)

ParameterRequiredTypeDescription
<interval>YesintegerThe number of specific time units to add
<timeUnit>YesstringThe unit of time to use with interval. Possible units are "Second", "Minute", "Hour", "Day", "Week", "Month", and "Year".
<format>NostringA custom format pattern. Default: UTC ISO format YYYY-MM-DDTHH:mm:ss.fffZ, which complies with ISO 8601.
<locale>NostringAn optional locale of culture information
Return valueTypeDescription
<updated-timestamp>stringThe current timestamp plus the specified number of time units

Example 1

Suppose the current timestamp is 2019-03-01T00:00:00.000Z. The example below adds five days to that timestamp:

getFutureTime(2, 'Week')

And returns the result 2019-03-15T00:00:00.000Z.

Example 2

Suppose the current timestamp is 2018-03-01T00:00:00.000Z. The example below adds five days to the timestamp and converts the result to MM-DD-YY format:

getFutureTime(5, 'Day', 'MM-DD-YY')

And returns the result 03-06-18.

Example 3

Suppose the current timestamp is 2020-05-01T00:00:00.000Z and the locale is de-DE. The example below adds 1 day to the timestamp:

getFutureTime(1,'Day', '', 'de-DE')

And returns the result 02.05.20 00:00:00.

getNextViableDate

Return the next viable date of a Timex expression based on the current date and an optionally specified timezone.

getNextViableDate(<timexString>, <timezone>?)

ParameterRequiredTypeDescription
<timexString>YesstringThe Timex string of the date to evaluate.
<timezone>NostringThe optional timezone.
Return valueTypeDescription
<nextViableTime>stringThe next viable date.

Examples

Say the date is 2020-06-12 and current time is 15:42:21.

These examples evaluate the Timex string for the next viable date based on the above date and time:

getPreviousViableDate("XXXX-12-20", "America/Los_Angeles")
getPreviousViableDate("XXXX-02-29")

And return the following strings respectively:

  • 2020-12-20
  • 2024-02-29

getNextViableTime

Return the next viable time of a Timex expression based on the current time and an optionally specified timezone.

getNextViableTime(<timexString>, <timezone>?)

ParameterRequiredTypeDescription
<timexString>YesstringThe Timex string of the time to evaluate.
<timezone>NostringThe optional timezone.
Return valueTypeDescription
<nextViableTime>stringThe next viable time.

Examples

Say the date is 2020-06-12 and current time is 15:42:21.

These examples evaluate a Timex string for the next viable time based on the above date and time:

getNextViableTime("TXX:12:14", "Asia/Tokyo")
getNextViableTime("TXX:52:14")

And return the following strings respectively:

  • T16:12:14
  • T15:52:14

getPastTime

Return the current timestamp minus the specified time units.

getPastTime(<interval>, <timeUnit>, '<format>'?)

ParameterRequiredTypeDescription
<interval>YesintegerThe number of specific time units to subtract
<timeUnit>YesstringThe unit of time to use with interval. Possible units are "Second", "Minute", "Hour", "Day", "Week", "Month", and "Year".
<format>NostringA custom format pattern. Default: UTC ISO format YYYY-MM-DDTHH:mm:ss.fffZ, which complies with ISO 8601.
Return valueTypeDescription
<updated-timestamp>stringThe current timestamp minus the specified number of time units

Example 1

Suppose the current timestamp is 2018-02-01T00:00:00.000Z. This example subtracts five days from that timestamp:

getPastTime(5, 'Day')

And returns the result 2019-01-27T00:00:00.000Z.

Example 2

Suppose the current timestamp is 2018-03-01T00:00:00.000Z. This example subtracts five days to the timestamp in the MM-DD-YY format:

getPastTime(5, 'Day', 'MM-DD-YY')

And returns the result 02-26-18.

Example 3

Suppose the current timestamp is 2020-05-01T00:00:00.000Z and the locale is de-DE. The example below subtracts 1 day from the timestamp:

getPastTime(1,'Day', '', 'de-DE')

And returns the result 31.04.20 00:00:00.

getPreviousViableDate

Return the previous viable date of a Timex expression based on the current date and an optionally specified timezone.

getPreviousViableDate(<timexString>, <timezone>?)

ParameterRequiredTypeDescription
<timexString>YesstringThe Timex string of the date to evaluate.
<timezone>NostringThe optional timezone.
Return valueTypeDescription
<previousViableDate>stringThe previous viable date.

Examples

Say the date is 2020-06-12 and current time is 15:42:21.

These examples evaluate a Timex string for the previous viable date based on the above date and time:

getPreviousViableDate("XXXX-12-20", "Eastern Standard Time")
getPreviousViableDate("XXXX-02-29")

And return the following strings respectively:

  • 2019-12-20
  • 2020-02-29

getPreviousViableTime

Return the previous viable time of a Timex expression based on the current date and an optionally specified timezone.

getPreviousViableTime(<timexString>, <timezone>?)

ParameterRequiredTypeDescription
<timexString>YesstringThe Timex string of the time to evaluate.
<timezone>NostringThe optional timezone.
Return valueTypeDescription
<previousViableTime>stringThe previous viable time.

Examples

Say the date is 2020-06-12 and current time is 15:42:21.

These examples evaluate a Timex string for the previous viable time based on the above date and time:

getPreviousViableTime("TXX:52:14")
getPreviousViableTime("TXX:12:14", 'Europe/London')

And return the following strings respectively:

  • T14:52:14
  • T15:12:14

getProperty

Return the value of a specified property or the root property from a JSON object.

Return the value of a specified property

getProperty(<JSONObject>, '<propertyName>')

ParameterRequiredTypeDescription
<JSONObject>YesobjectThe JSON object containing the property and values.
<propertyName>NostringThe name of the optional property to access values from.
Return valueTypeDescription
valuestringThe value of the specified property in the JSON object.

Example

Say you have the following JSON object:

{
   "a:b" : "a:b value",
   "c":
   {
        "d": "d key"
    }
}

These example retrieve a specified property from the above JSON object:

getProperty({"a:b": "value"}, 'a:b')
getProperty(c, 'd')

And return the following strings respectively:

  • a:b value
  • d key

Return the root property

getProperty('<propertyName>')

ParameterRequiredTypeDescription
<propertyName>YesstringThe name of the optional property to access values from the root memory scope.
Return valueTypeDescription
valuestringThe value of the root property in a JSON object.

Example

Say you have the following JSON object:

{
   "a:b" : "a:b value",
   "c":
   {
        "d": "d key"
    }
}

This example retrieves the root property from the above JSON object:

getProperty("a:b")

And returns the string a:b value.

getTimeOfDay

Returns time of day for a given timestamp.

getTimeOfDay('<timestamp>')

Time returned is one of the following strings:

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the specified timestamp
Return valueTypeDescription
<time-of-day>stringThe time of day for the specified timestamp

Listed below are the strings associated with the time of day:

Time of dayTimestamp
midnight12AM
morning12:01AM – 11:59PM
afternoon12PM
evening06:00PM – 10:00PM
night10:01PM – 11:59PM

Example

getTimeOfDay('2018-03-15T08:00:00.000Z')

Returns the result morning.

greater

Check whether the first value is greater than the second value. Return true if the first value is more, or return false if less.

greater(<value>, <compareTo>)
greater('<value>', '<compareTo>')

ParameterRequiredTypeDescription
<value>Yesinteger, float, or stringThe first value to check whether greater than the second value
<compareTo>Yesinteger, float, or stringThe comparison value
Return valueTypeDescription
true or falseBooleanReturn true if the first value is greater than the second value. Return false if the first value is equal to or less than the second value.

Example

These examples check whether the first value is greater than the second value:

greater(10, 5)
greater('apple', 'banana')

And return the following results respectively:

  • true
  • false

greaterOrEquals

Check whether the first value is greater than or equal to the second value. Return true when the first value is greater or equal, or return false if the first value is less.

greaterOrEquals(<value>, <compareTo>)
greaterOrEquals('<value>', '<compareTo>')

ParameterRequiredTypeDescription
<value>Yesinteger, float, or stringThe first value to check whether greater than or equal to the second value
<compareTo>Yesinteger, float, or stringThe comparison value
Return valueTypeDescription
true or falseBooleanReturn true if the first value is greater than or equal to the second value. Return false if the first value is less than the second value.

Example

These examples check whether the first value is greater or equal than the second value:

greaterOrEquals(5, 5)
greaterOrEquals('apple', 'banana')

And return the following results respectively:

  • true
  • false