Instalink.io Scripting Language Operations

Type Conversions

NONE

Description

Passes the value not transformed

Example

input:

NONE("string")

output:

"string"

INTEGER

Description

Transforms the value into and integer

Example

input:

INTEGER("12345")

output:

12345

FLOAT

Description

Transforms the value into and float

Example

input:

FLOAT(123)

output:

123.0

STRING

Description

Transforms the value into and string

Example

input:

STRING(12345)

output:

"12345"

MAP

Description

Transforms the value into and map

Example

input:

MAP([[ "Service":"InstaLink"], ["Rating": "\*\*\*\*\*"]])

output:

{ "Service": "InstaLink", "Rating": "\*\*\*\*\*" }

ARRAY

Description

Transforms the value into an array

Example

input:

ARRAY("string")

output:

["string"]

DATE

Description

Transforms the value into a date. Can have a default value as a second argument

Example

input:

DATE(9000)

output:

'1970-01-01T02:30:00.000Z'

input:

DATE('2017-08-29T21:45:03.129Z')

output:

'2017-08-29T21:45:03.129Z'

input:

DATE('Tue Aug 29 2017 11:00:49 GMT-0600 (MDT)')

output:

'2017-08-29T17:00:49.000Z'

input:

DATE("BadData")

output:

'1970-01-01T00:00:00.000Z'

input:

DATE("BadData",'2017-08-29T21:45:03.129Z')

output:

'2017-08-29T21:45:03.129Z'

DATE_TO_STRING

Description

Transforms the date value into a string

Valid Date Format Strings:

  • "ddd mmm dd yyyy HH:MM:ss"
  • "m/d/yy"
  • "m/d/yyyy"
  • "mm/dd/yy"
  • "mm/dd/yyyy"
  • "d/m/yy"
  • "d/m/yyyy"
  • "dd/mm/yy"
  • "dd/mm/yyyy"
  • "mmm d, yyyy"
  • "mmmm d, yyyy"
  • "dddd, mmmm d, yyyy"
  • "h:MM TT"
  • "h:MM:ss TT"
  • "h:MM:ss TT Z"
  • "yyyy-mm-dd"
  • "HH:MM:ss"
  • "yyyy-mm-dd'T'HH:MM:ss"
  • "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"

Example

input:

DATE_TO_STRING(DATE("2017-08-30T17:36:23.077Z"), "UTC:ddd mmm dd yyyy HH:MM:ss")

output:

"Wed Aug 30 2017 17:36:23"

input:

DATE_TO_STRING(DATE("2017-08-30T17:36:23.077Z"), "UTC:mm/dd/yyyy")

output:

"08/30/2017"

TIMESTAMP

Description

Transforms the value into a timestamp

Example

input:

TIMESTAMP(DATE(1000))

output:

1000

input:

TIMESTAMP('Tue Aug 29 2017 11:00:49 GMT-0600 (MDT)')

output:

1504026049
Can take a default value as a second argument

input:

TIMESTAMP(null, 'Tue Aug 29 2017 11:00:49 GMT-0600 (MDT)')

output:

1504026049

BOOLEAN

Description

Transforms the value into a boolean

Example

input:

BOOLEAN("TRUE")

output:

true

input:

BOOLEAN(null)

output:

false
Can take a default value as a second argument

input:

BOOLEAN(null, true)

output:

true

Array Operations

ARRAY_GET

Description

Retrieves a value from an array at the index specified

Example

input:

ARRAY_GET(["salad", "potato"], 1)

output:

"potato"

input:

ARRAY_GET(["salad", "potato", "chicken", "waffles", "home", "fries", "banana", "shake"], -2)

output:

"banana"
It can take a default value as the third argument and return it if the index is out of bounds

input:

ARRAY_GET(["salad", "potato", "chicken", "waffles", "home", "fries", "banana", "shake"], 8, "casserole")

output:

"casserole"

ARRAY_SET

Description

Sets the value in an array at the index specified.

It can also fill in the size of the array specified with that value if the index is bigger than the current array size

Example

input:

ARRAY_SET(["salad", "potato"], 1, "bacon")

output:

["salad", "bacon"]

input:

ARRAY_SET(["salad", "potato", "chicken", "waffles", "shake"], -2, "fries")

output:

["salad", "potato", "chicken", "fries", "shake"]

ARRAY_DELETE

Description

Removes the value in an array at the index specified.

Example

input:

ARRAY_DELETE(["salad", "potato"], 1)

output:

["salad"]

input:

ARRAY_DELETE(["salad", "potato", "chicken", "waffles", "shake"], -2)

output:

["salad", "potato", "chicken", "shake"]

ARRAY_LENGTH

Description

Returns the number of elements in the array

Example

input:

ARRAY_LENGTH["salad", "potato", "chicken", "waffles", "shake"])

output:

5

ARRAY_FIRST

Description

Returns the first element in the array

Example

input:

ARRAY_FIRST["salad", "potato", "chicken", "waffles", "shake"])

output:

"salad"

ARRAY_TAIL

Description

Returns the array with the first element removed

Equivalent to: ARRAY_DELETE(array,0)

Example

input:

ARRAY_TAIL(["salad", "potato", "chicken", "waffles", "shake"])

output:

["potato", "chicken", "waffles", "shake"]

ARRAY_LAST

Description

Returns the last element in the array

Example

input:

ARRAY_LAST["potato", "chicken", "waffles", "shake"])

output:

"shake"

ARRAY_INIT

Description

Returns the array with the last element removed

Equivalent to: ARRAY_DELETE(array,-1)

Example

input:

ARRAY_INIT(["salad", "potato", "chicken", "waffles", "shake"])

output:

["salad", "potato", "chicken", "waffles"]

ARRAY_PLUCK

Description

Returns the value from each object in an array that matches the path given

Example

input:

ARRAY_PLUCK([ ['a'=>['b'=>['1']]], ['a'=>['c'=>'2'] ], ['a'=>['b'=>3]] ], 'a.b')

output:

[ ['1'] , 3 ]

ARRAY_SAMPLE

Description

Returns an element from a random location in the array

Example

input:

ARRAY_SAMPLE(["salad", "potato", "chicken", "waffles", "shake"])

output:

"shake"

ARRAY_EACH

Description

Transforms the value into an array

Same as ARRAY()

Example

input:

ARRAY("string")

output:

["string"]

ARRAY_CONCAT

Description

Joins multiple arrays together

Example

input:

ARRAY_CONCAT(["salad", "potato"], "chicken", ["waffles", "shake"])

output:

["salad", "potato", "chicken", "waffles", "shake"]

ARRAY_FILTER

Description

Filters out map/objects from an array using a map, keeping all the non-matching items

Example

input:

ARRAY_FILTER([['a'=>'pickme', 'b'=>'$5'], ['a'=>'not me','b'=>'$0']], ['a'=>'not me'])

output:

[['a'=>'pickme', 'b'=>'$5']]

ARRAY_MATCH

Description

Collect map/objects from an array using a map, keeping all of them matching the key=>values

Example

input:

ARRAY_MATCH([['a'=>'pickme', 'b'=>'$5'], ['a'=>'not me','b'=>'$0']], ['a'=>'pickme'])

output:

[['a'=>'pickme', 'b'=>'$5']]

ARRAY_UNIQUEBY

Description

Collect map/objects from an array using "path" of keys, keeping each of the first instances of the items having the key path that's passed in.

Example

input:

ARRAY_UNIQEBY([['a'=>'pickme', 'b'=>'$5'], ['a'=>'not me','b'=>'$0']], 'a')

output:

[['a'=>'pickme', 'b'=>'$5']]

input:

ARRAY_UNIQEBY([['a'=>['b'=>'chicken'],'d'=>'gum'], ['a'=>['c'=>'dinner']], ['b'=>'apple']], 'a')

output:

[['a'=>['b'=>'chicken'], 'd'=>'gum'], ['a'=>['c'=>'dinner']]]

input:

ARRAY_UNIQEBY([['a'=>['b'=>'chicken'],'d'=>'gum'], ['a'=>['c'=>'dinner']], ['b'=>'apple']], 'b')

output:

[['b'=>'apple']]

input:

ARRAY_UNIQEBY([['a'=>['b'=>'chicken'],'d'=>'gum'], ['a'=>['c'=>'dinner']], ['b'=>'apple']], 'a.b')

output:

[['a'=>['b'=>'chicken'], 'd'=>'gum'])

input:

ARRAY_UNIQEBY([['a'=>['b'=>'chicken'],'d'=>'gum'], ['a'=>['c'=>'dinner']], ['b'=>'apple']], 'a[b]')

output:

[['a'=>['b'=>'chicken'], 'd'=>'gum'])

ARRAY_SORTBY

Description

Sort the array by a key

Example

input:

ARRAY_SORTBY([['a'=>2, 'b'=>9],['a'=>1, 'b'=>4],['a'=>3,'b'=>1]], 'a')

output:

[['a'=>1, 'b'=>4], ['a'=>2, 'b'=>9], ['a'=>3,'b'=>1]]

input:

ARRAY_SORTBY([['a'=>['b'=>2], 'b'=>9],['a'=>['b'=>1], 'b'=>4],['a'=>['b'=>3],'b'=>1]], 'a.b')

output:

[['a'=>['b'=>1], 'b'=>4], ['a'=>['b'=>2], 'b'=>9], ['a'=>['b'=>3],'b'=>1]]

input:

ARRAY_SORTBY([['a'=>['b'=>2], 'b'=>9],['a'=>['b'=>1], 'b'=>4],['a'=>['b'=>3],'b'=>1]], 'a[b]')

output:

[['a'=>['b'=>1], 'b'=>4], ['a'=>['b'=>2], 'b'=>9], ['a'=>['b'=>3],'b'=>1]]

ARRAY_FLATTEN

Description

Does a "Shallow" flattening of an array (only up to one level deep). Most Efficient

Example

input:

ARRAY_FLATTEN([ ['a'], 'b', [['c']] ])

output:

['a', 'b', ['c']]

ARRAY_FLATTEN_DEEP

Description

Does a "Deep" flattening of an array (infinite levels deep).

Example

input:

ARRAY_FLATTEN_DEEP([ ['a'], 'b', [['c']] ])

output:

['a', 'b', 'c']

ARRAY_JOIN

Description

Joins an array into a string, inserting the dividing character between each element if supplied

Example

input:

ARRAY_JOIN(['ba','a','a'],'n')

output:

"Banana"

input:

ARRAY_JOIN(['ba','a','a'])

output:

"Baaa"

ARRAY_REVERSE

Description

Joins an array into a string, inserting the dividing character between each element if supplied

Example

input:

ARRAY_REVERSE(['x', 'y', 'z', 'p', 'd', 'q'])

output:

['q', 'd', 'p', 'z', 'y', 'x']

ARRAY_TRANSPOSE

Description

Pivots an array of arrays

Example

input:

ARRAY_TRANSPOSE([[1,2,3],[4,5,6]])

output:

ARRAY_TRANSPOSE([[1,4],[2,5],[3,6]])

ARRAY_GET_INDEX

Description

Gets the array index for the first occurance of the desired element.

Example

input:

ARRAY_GET_INDEX(['x', 'y', 'z', 'p', 'd', 'q'], 'y')

output:

1

ARRAY_CONTAINS

Description

Returns true if the array contains the element, and false if it isn't in the array

Example

input:

ARRAY_CONTAINS(['x', 'y', 'z', 'p', 'd', 'q'], 'y')

output:

true

ARRAY_SUB

Description

Returns a section of the array by passing in the indexes for the first element and the element after the last element to be captured.

Example

input:

ARRAY_SUB(['x', 'y', 'z', 'p', 'd', 'q'], 2, 3)

output:

['z']

ARRAY_GROUP_BY

Description

Groups objects/maps into subarrays using the key that's passed in as what to group them with

Example

[['a'=> 1, 'b'=> 2], ['a'=> 4, 'b'=> 2], ['a'=> 4, 'b'=> 4], ['a'=> 1, 'b'=> 6], ['a'=> 3, 'b'=> 4]]
input:

ARRAY_GROUP_BY([['a'=>1,'b'=>2],['a'=>4,'b'=>2],['a'=>4,'b'=>4],['a'=>1,'b'=> 6],['a'=>3, 'b'=>4]], 'a')

output:

[  [['a'=>1,'b'=>2],['a'=>1,'b'=> 6]], [['a'=>4,'b'=>2],['a'=>4,'b'=>4]], [['a'=>3, 'b'=>4]] ]

ARRAY_AGGREGATE

Description

Goes through an array of objects/maps and combines them together into a single map, aggregating on the map passed in as the aggregate template

aggregate types:

  • sum
  • max
  • min
  • first
  • last
  • average
  • push

Example

input:

ARRAY_AGGREGATE([ ['item'=>'abc', 'qty'=>2], ['item'=>'abc', 'qty'=>3] ], [['qty','sum']])

output:

['qty'=>5]

input:

ARRAY_AGGREGATE([ ['item'=>'abc', 'qty'=>2], ['item'=>'abc', 'qty'=>3] ], [['qty','sum', 'item','first']])

output:

['qty'=>5, 'item'=>'abc']

ARRAY_GROUP_AGGREGATE

Description

Goes through an array of objects/maps, groups them together based on the grouping key, and then combines each of the groups together into a single map in each group, aggregating on the map passed in as the aggregate template

aggregate types:

  • sum
  • max
  • min
  • first
  • last
  • average
  • push

Example

input:

ARRAY_GROUP_AGGREGATE([ ['item'=>'abc', 'qty'=>2], ['item'=>'abc', 'qty'=>3] ], 'item', [['qty','sum']])

output:

[['qty'=>5]]

input:

ARRAY_GROUP_AGGREGATE([ [['item'=>'abc', 'qty'=>2], ['item'=>'abc', 'qty'=>3]] ], 'item', [['qty','sum', 'item','first']])

output:

[['qty'=>5, 'item'=>'abc']]

ARRAY_UNION

Description

Combines two arrays together, removing any duplicate keys

Example

input:

ARRAY_UNION([1,2,3],[2,3,4],[5,6,7])

output:

[1,2,3,4,5,6,7]

input:

ARRAY_UNION([ [1,2,3],[2,3,4] ] , [ [5,6,7] ])

output:

[  [1,2,3,4,5,6,7] ]

ARRAY_DIFFERENCE

Description

Returns all the items that exist in the left hand side that don't exit on the right

Example

input:

ARRAY_DIFFERENCE([1,2,3],[2,3,4])

output:

[1]

input:

ARRAY_DIFFERENCE([ [1,2,3],[2,3,4] ] , [ [4,5,6,7] ])

output:

[ [1,2,3] ]

ARRAY_INTERSECTION

Description

Returns all the items that exist in both the left hand side and the right hand side

Example

input:

ARRAY_INTERSECTION([1,2,3],[2,3,4])

output:

[2,3]

input:

ARRAY_INTERSECTION([ [1,2,3],[2,3,4] ] , [ [4,5,6,7] ])

output:

[ [4] ]

ARRAY_TO_MAP

Description

Converts an array of objects into an array of arrays with the first element of the inner array being a copy of a specified value in the object, and the second element being the original object.

Example

input:

ARRAY_TO_MAP([['name'=>'Alice', 'ssn'=>'123'],['name'=>'Bob', 'ssn'=>'456'],['name'=>'Chuck', 'ssn'=>'789']],'name')

output:

[['Alice' => ['name'=>'Alice', 'ssn'=>'123']], ['Bob' => ['name'=>'Bob', 'ssn'=>'456']], ['Chuck' => ['name'=>'Chuck', 'ssn'=>'789']]]

Text Operations

TEXT_CONCAT

Description

Creates a new string consisting of the second string appended to the end of the first string

Example

input:

TEXT_CONCAT("SoFly","ForAWiFi")

output:

"SoFlyForAWiFi"

TEXT_PREPEND

Creates a new string consisting of the first string appended to the end of the second string

Example

input:

TEXT_PREPEND("ForAWiFi", "SoFly")

output:

"SoFlyForAWiFi"

TEXT_APPEND

Description

Creates a new string consisting of the second string appended to the end of the first string

Example

input:

TEXT_APPEND("SoFly","ForAWiFi")

output:

"SoFlyForAWiFi"

TEXT_SUB

Description

Returns a section of the string starting at the index given going to the count of characters to the right.

Example

input:

TEXT_SUB("Top of the morning",7,5)

output:

"the m"

TEXT_REPLACE

Description

Replaces all occurances of the substring/regex with the replacement string

Example

input:

TEXT_REPLACE("Top of the morning", "morning", "day")

output:

"Top of the day"

Regex's can have flags for case insensitive searches and global replacement
input:

TEXT_REPLACE("Top of the morning", "/o/g", "0")

output:

"T0p 0f the m0rning"

TEXT_LENGTH

Description

Returns the length of the string that is passed in

Example

input:

TEXT_LENGTH("Top of the morning")

output:

18

TEXT_LOWER_CASE

Description

Returns a copy of the string all lowercased

Example

input:

TEXT_LOWER_CASE("Top of the morning")

output:

"top of the morning"

TEXT_UPPER_CASE

Description

Returns a copy of the string all uppercase

Example

input:

TEXT_UPPER_CASE("Top of the morning")

output:

"TOP OF THE MORNING"

TEXT_CAPITALIZE_WORDS

Description

Returns a copy of the string with the first character of all the words capitalized

Example

input:

TEXT_CAPITALIZE_WORDS("Top of the morning")

output:

"Top Of The Morning"

TEXT_TRIM

Description

Returns a copy of the string with all the whitespace trimmed off of both sides of the string

Example

input:

TEXT_TRIM("   Top of the morning   ")

output:

"Top of the morning"

TEXT_TRIM_LEFT

Description

Returns a copy of the string with all the whitespace trimmed off of the left side of the string

Example

input:

TEXT_TRIM_LEFT("   Top of the morning   ")

output:

"Top of the morning   "

TEXT_TRIM_RIGHT

Description

Returns a copy of the string with all the whitespace trimmed off of the right side of the string

Example

input:

TEXT_TRIM_RIGHT("   Top of the morning   ")

output:

"   Top of the morning"

TEXT_SPLIT

Description

Splits the string based on the substring passed in

Example

input:

TEXT_SPLIT("Top of the morning", " ")

output:

["Top","of","the","morning"]

TEXT_LINES

Description

Splits the string on newlines

Example

input:

TEXT_LINES("Top\nof\nthe\nmorning")

output:

["Top","of","the","morning"]

TEXT_WORDS

Description

Splits the string on spaces

Example

input:

TEXT_SPLIT("Top of the morning", " ")

output:

["Top","of","the","morning"]

Boolean Operations

LESS_THAN

Description

Returns a boolean value representing if the left hand argument is less than the right argument

Example

input:

LESS_THAN(0,2)

output:

true

GREATER_THAN

Description

Returns a boolean value representing if the left hand argument is greater than the right argument

Example

input:

GREATER_THAN(0,2)

output:

false

LESS_THAN_OR_EQUAL

Description

Returns a boolean value representing if the left hand argument is less than the right argument

Example

input:

LESS_THAN_OR_EQUAL(0,2)

output:

true

GREATER_THAN_OR_EQUAL

Description

Returns a boolean value representing if the left hand argument is greater than the right argument

Example

input:

GREATER_THAN_OR_EQUAL(0,2)

output:

false

EQUAL

Description

Returns a boolean value representing the arguments are both the same

Example

input:

EQUAL(2,2)

output:

true

NOT_EQUAL

Description

Returns a boolean value representing the arguments are both different

Example

input:

NOT_EQUAL(2,2)

output:

false

AND

Description

Returns a boolean value representing the arguments are both true

Example

input:

AND(true,true)

output:

true

OR

Description

Returns a boolean value representing either arguments are true

Example

input:

OR(true,false)

output:

true

XOR

Description

Returns true when only one argument is true

Example

input:

XOR(true,false)

output:

true

input:

XOR(true,true)

output:

false

Date/Time Operations

DATE_YEARS_AGO

Description

Returns how many years ago the first date is from the second date

Example

input:

DATE_YEARS_AGO('2017-08-30T17:36:23.077Z', '2017-08-30T17:36:23.077Z')

output:

0

input:

DATE_YEARS_AGO('2016-08-30T17:35:23.077Z', '2017-08-30T17:36:23.077Z')

output:

1
If no second argument is passed in, the current date is used

DATE_MONTHS_AGO

Description

Returns how many months ago the first date is from the second date

Example

input:

DATE_MONTHS_AGO('2017-08-30T17:36:23.077Z', '2017-08-30T17:36:23.077Z')

output:

0

input:

DATE_MONTHS_AGO('2016-08-30T17:35:23.077Z', '2017-08-30T17:36:23.077Z')

output:

12
If no second argument is passed in, the current date is used

CURRENT_DATE

Description

Returns the current date

Example

input:

CURRENT_DATE()

output:

'2018-07-01T17:35:23.077Z'

whatever the current date is

CURRENT_TIMESTAMP

Description

Returns the current date and time as a unix timestamp

Example

input:

CURRENT_TIMESTAMP()

output:

1530466523

whatever the current date/time is

DATE_YEAR

Description

Returns the year from a timestamp

Example

input:

DATE_YEAR('2017-08-30T17:36:23.077Z')

output:

2017

DATE_MONTH

Description

Returns the month number from a timestamp

Example

input:

DATE_MONTH('2017-08-30T17:36:23.077Z')

output:

8

DATE_MONTH_STRING

Description

Returns the month name

Example

input:

DATE_MONTH_STRING('2017-08-30T17:36:23.077Z')

output:

'August'

DATE_DAY_OF_MONTH

Description

Returns the day of the month

Example

input:

DATE_DAY_OF_MONTH('2017-08-30T17:36:23.077Z')

output:

30

DATE_DAY_OF_WEEK

Description

Returns the numeric day of the week, starting with Monday as 1

Example

input:

DATE_DAY_OF_WEEK('2017-08-30T17:36:23.077Z')

output:

3

Wednesday

DATE_DAY_OF_WEEK_STRING

Description

Returns the name of the day of the week

Example

input:

DATE_DAY_OF_WEEK('2017-08-30T17:36:23.077Z')

output:

'Wednesday'

DATE_TRUNCATE_TO_MINUTE

Description

Returns the date passed in, with the seconds set to zero

Example

input:

DATE_TRUNCATE_TO_MINUTE('2017-08-30T17:36:23.077Z')

output:

'2017-08-30T17:36:00.000Z'

DATE_TRUNCATE_TO_HOUR

Description

Returns the date passed in, with the minutes and seconds set to zero

Example

input:

DATE_TRUNCATE_TO_HOUR('2017-08-30T17:36:23.077Z')

output:

'2017-08-30T17:00:00.000Z'

DATE_TRUNCATE_TO_DAY

Description

Returns the date passed in, with the hour, minutes and seconds set to zero

Example

input:

DATE_TRUNCATE_TO_DAY('2017-08-30T17:36:23.077Z')

output:

'2017-08-30T00:00:00.000Z'

DATE_TRUNCATE_TO_MONTH

Description

Returns the date passed in, with the day, hour, minutes and seconds set to zero

Example

input:

DATE_TRUNCATE_TO_MONTH('2017-08-30T17:36:23.077Z')

output:

'2017-08-01T00:00:00.000Z'

DATE_TRUNCATE_TO_YEAR

Description

Returns the date passed in, with the month, day, hour, minutes and seconds set to zero

Example

input:

DATE_TRUNCATE_TO_YEAR('2017-08-30T17:36:23.077Z')

output:

'2017-01-01T00:00:00.000Z'

Math Operations

MATH_NEGATE

Description

Returns the equivalent of multiplying the number by negative one

Example

input:

MATH_NEGATE(9)

output:

-9

input:

MATH_NEGATE(-0.4)

output:

0.4

MATH_ADD

Description

Returns the sum of the two arguments

Example

input:

MATH_ADD(9,2)

output:

11

MATH_SUBTRACT

Description

Returns the difference of the two arguments

Example

input:

MATH_SUBTRACT(9,2)

output:

7

MATH_MULTIPLY

Description

Returns the product of the two arguments

Example

input:

MATH_MULTIPLY(9,2)

output:

18

MATH_DIVIDE

Description

Returns the quotient of the two arguments

Example

input:

MATH_DIVIDE(9,2)

output:

4.5

MATH_DIVIDE_INT

Description

Returns the integer quotient of the two arguments

Example

input:

MATH_DIVIDE_INT(9,2)

output:

4

MATH_REMAINDER

Description

Returns the integer remainder of the quotient of the two arguments

Example

input:

MATH_REMAINDER(9,2)

output:

1

MATH_POWER

Description

Returns the product of the first argument to the power of the second argument

Example

input:

MATH_POWER(9,2)

output:

81

MATH_SQUARE_ROOT

Description

Returns the square root of the argument

Example

input:

MATH_SQUARE_ROOT(81)

output:

9

MATH_CUBE_ROOT

Description

Returns the cube root of the argument

Example

input:

MATH_CUBE_ROOT(27)

output:

3

MATH_ABSOLUTE_VALUE

Description

Returns the positive version of the argument

Example

input:

MATH_ABSOLUTE_VALUE(-7)

output:

7

MATH_CEILING

Description

Returns the number, rounded up to the nearest whole number

Example

input:

MATH_CEILING(7.1)

output:

8

MATH_FLOOR

Description

Returns the number, rounded down to the nearest whole number

Example

input:

MATH_FLOOR(7.1)

output:

7

MATH_TRUNCATE

Description

Returns the number, rounded towards zero. (if it's negative, it gets rounded up. If it's positive, it's rounded down)

Example

input:

MATH_TRUNCATE(-7.1)

output:

-7

MATH_ROUND

Description

Returns the number, rounded down to the nearest whole number if it's less than half way to the next largest whole number, otherwise it's rounded up

Example

input:

MATH_ROUND(-7.1)

output:

-7

MATH_RANDOM

Description

Returns a random number less that the number passed in, but greater than 0

Example

input:

MATH_RANDOM(14)

output:

10.0
Not guaranteed to be truely random

MATH_RANDOM_INT

Description

Returns a random number less that the number passed in, but greater than 0, as a whole number

Example

input:

MATH_RANDOM(14)

output:

10

Map Operations

MAP_GET

Description

Retrieves a value from a key=>value pair map

Example

input:

MAP_GET(["salad"=>"potato"], "salad")

output:

"potato"
It can take a default value as the third argument

input:

MAP_GET(["salad"=>"potato"], "fries", "casserole")

output:

"casserole"

MAP_PAIRS

Description

Transforms objects and arrays into an array of arrays, with each of the child arrays containing a key,value pair

Example

input:

MAP_PAIR(["salad","potato"])

output:

[[0,"salad"],[1,"potato"]]

input:

MAP_PAIR(["salad"=>"potato"])

output:

[["salad","potato"]]

MAP_HAS

Description

Returns true or false, depending on if the key exists in the map/object

Example

input:

MAP_HAS(["salad"=>"potato"], "salad"))

output:

true

input:

MAP_HAS(["salad"=>"potato"], "chicken"))

output:

false

MAP_SIZE

Description

Returns the number of key value pairs that are in the map/object

Example

input:

MAP_SIZE(["salad"=>"potato"]))

output:

1

input:

MAP_SIZE(["salad"=>"potato", "chicken"=>"frys"]))

output:

2

MAP_MERGE

Description

Combines two or more maps/objects together into one map. If there are multiples of the same key, the last map with that key is used for that key value pair

Example

input:

MAP_MERGE(["salad"=>"potato", "chicken"=>"waffles"], ["chicken"=>"fries", "banana"=>"shake"] )

output:

["salad"=>"potato", "chicken"=>"fries", "banana"=>"shake"]

MAP_KEYS

Description

Returns all the keys for a map as an array

Example

input:

MAP_KEYS(["salad"=>"potato", "chicken"=>"waffles", "home"=>"fries", "banana"=>"shake"] )

output:

["salad", "chicken", "home", "banana"]

MAP_VALUES

Description

Returns all the values for a map as an array

Example

input:

MAP_VALUES(["salad"=>"potato", "chicken"=>"waffles", "home"=>"fries", "banana"=>"shake"] )

output:

["potato", "waffles", "fries", "shake"]

MAP_SET

Description

Returns a map with the specified key set to the value passed in

Example

input:

MAP_SET(["salad"=>"potato"], "salad", "carrot" )

output:

["salad"=>"carrot"]

MAP_DELETE

Description

Returns a map with the specified key removed

Example

input:

MAP_DELETE(["salad"=>"potato", "chicken"=>"waffles", "home"=>"fries", "banana"=>"shake"], "salad")

output:

["chicken"=>"waffles", "home"=>"fries", "banana"=>"shake"]

Encoding operations

ENCODE_BASE64

Description

Returns the base 64 representation of the string passed in

Example

input:

ENCODE_BASE64('abc')

output:

'YWJja'

DECODE_BASE64

Description

Returns the regular string representation of the base 64 string

Example

input:

ENCODE_BASE64('YWJja')

output:

'abc'

ENCODE_JSON

Description

Returns the JSON representation of the map passed in

Example

input:

ENCODE_JSON({a: 1})

output:

"{'a': 1}"

DECODE_JSON

Description

Returns the regular string representation of the json map

Example

input:

DECODE_JSON("{'a': 1}")

output:

"{'a': 1}"

ENCODE_CSV

Description

Returns a CSV string representation of the array of objects passed in

Example

input:

ENCODE_CSV([{'a': 1, 'b': 'lmnop'}])

output:

'"a","b"\r\n"1","lmnop"\r\n'

ENCODE_URI

Description

Returns a URI escaped string representation of the string passed in

Example

input:

ENCODE_URI('%20 /apples&birds , whatevs')

output:

'%2520%20%2Fapples%26birds%20%2C%20whatevs'

DECODE_URI

Description

Returns the decoded representation of the string passed in

Example

input:

ENCODE_URI('%2520%20%2Fapples%26birds%20%2C%20whatevs')

output:

'%20 /apples&birds , whatevs'

Syntax

MAP

The syntax for a map is the key / value pair separated by a => (rocket), inside square brackets [].

Example

[ "duck"=>"billed" ]

If there are multiple pairs, the pairs a separated by a comma from the previous pair, but still inside the original brackets.

Example

[ "duck"=>"billed", "quick" => "witted" ]

Blocks

a block looks like the following:

{ |x| x < 1 }

Accessing the values of counters

${KEY:0}

gets the loop counter closest to the root

Advanced Techniques

Conditionally setting a value with MAP_GET

When you have logic that you want to set the result variable to 2 or more different values depending on conditions,MAP_GET can help.

If you want to write something similar to:

If (VALUE == 1) then
            RESULT = "did it"
            else
            RESULT = "didn't do it"
            end

You could do that like this:

MAP_GET([1=>"did it"], VALUE, "didn't do it")

Conditionally setting many different values with MAP_GET

You could also do many conditions in a similar manner, just add it to the key value pair. So something like:

If (VALUE == 1) then
              RESULT = "did it"
              else if (VALUE == 2) then
              RESULT = "did something else"
              else
              RESULT = "didn't do it"
              end

would be written as:

MAP_GET([1=>"did it", 2=>"did something else"], VALUE, "didn't do it")

Conditionally setting multiple values with MAP_GET

MAP_GET could be used in a similar manner for conditionally doing other logic if instead of returning strings, you call other methods instead. If you were wanting to do something like:

if (VALUE == 1) then
                RESULT.first_name = "Oscar"
                else if (VALUE == 2) then
                RESULT.last_name = "Meyer"
                else
                RESULT.error = "DIDN'T SET NAME"
                end

This could be written as:

MAP_GET([ 1=>MAP_SET(${my_vals},"first_name", "Oscar"), 2=>MAP_SET(${my_vals},"last_name", "Meyer")],VALUE, MAP_SET(${my_vals}, "error" => "DIDN'T SET NAME"))
In the above examples, the instalink code output is set to my_vals as the output variable