Generic Functions in QPR ProcessAnalyzer: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
No edit summary
Line 338: Line 338:
||In (Boolean)
||In (Boolean)
||
||
# Object which to search
# Array where to search the object
# Array where to find the object
# ...
||
||
Function tests whether the current context object is in given array. Returns true only if the context object is equal to at least one object in given array. This function only tests atomic objects and the top level of the given array.
Function checks whether the current context object is in given array, and returns either ''true'' or ''false''. Note that the searched object is not given as a parameter, but it's the context object for the function (see the examples).


Examples:
Examples:

Revision as of 12:30, 1 April 2018

Generic Properties and Functions are available for all objects.

Generic Properties

Property Description
_

Refers to the current context.

_empty

Returns an object which represent a non-existent value. Textual representation of this value is "EMPTY".

_remove

Returns an object which represent a value that should automatically be recursively pruned out of the resulting hierarchy object when processing chained expressions. If all the child values of one context object used in chaining expressions return this object, the root object itself will also be pruned out of the resulting hierarchy object.

Examples:

Both:
[1,2]._remove
[1,2].Where(_==3, _remove)
Return EMPTY

whereas

[1,2].Where(_==3, _empty)
[1,2].Where(_==3)
[1,2]._empty
Returns an empty collection (collection of length 0).

For("i", 0, i < 10, i + 1, i).Where(_ % 2 == 0)
For("i", 0, i < 10, i + 1, i).If(_ % 2 == 0, _, _remove)
Both return:
[0, 2, 4, 6, 8]
CalcId (string)

Returns an id that is unique between all QPR ProcessAnalyzer objects. CalcId is remains the same at least for the duration of the expression calculation. It is possible that CalcId for an object is different in the next calculation. CalcId is EMPTY for other than QPR ProcessAnalyzer objects.

ComparisonEventLog (EventLog)

Returns the current comparison EventLog in whose context the expression is being evaluated. Comparison EventLog is available only when the KPI analysis request has been initialized with RuntimeComparison parameter set to true.

CurrentUser (User) Returns the current user as User object.
Models (Model*) All Model objects in the QPR ProcessAnalyzer server (that the user have rights).
Now (DateTime) DateTime object representing the current date and time.
Null

Returns a special null value. Null value is similar to EMPTY value, except null values can also be recursed. In some occasions null values can be converted into numbers and then they act as 0.

Projects (Project*) All Projects in the QPR ProcessAnalyzer server (that the user have rights).

Aggregation Functions

Aggregation functions are performed by default to the leaf level (the deepest level). Aggregation means that leaf level arrays are replaced by the aggregated values, and thus the depth of the hierarchy decreases by one. There are following aggregation functions available: Average, Count, Min, Max and Sum.

Examples:

Count([[1, 2], [3, 4, 5]])
Returns: [2, 3]

Sum([[1, 2], [3, 4, 5]])
Returns: [3, 12]

In addition to the aggregation functions, functions that modify the contents of leaf arrays (OrderBy, Distinct, ...), the operation will be performed separately for every leaf array.

OrderByValue([[4, 3], [2, 1]])
Returns: [[3, 4], [1, 2]]

Mathematical functions

Function Parameters Description
Ceiling (Integer)
  • Number (Float)

Returns the smallest integer greater than or equal to the specified number.

Floor (Integer)
  • Number (Float)

Returns the largest integer less than or equal to the specified number.

Round (Float)
  1. Number to be rounded (Float)
  2. Number of decimals (Integer)

Rounds a value to the nearest integer or to the specified number of fractional digits.

Ordering functions

Function Parameters Description
OrderBy (array)
  1. Array to order
  2. Order expression

Orders the given array using values from the given order expression. The order expression is evaluated once for each item in the array. The order expression supports all atomic (=not collection) primitive value types.

Examples:

OrderBy(["a", "x", "b", "z", "n", "l", "a"], _)
Return:
["a", "a", "b", "l", "n", "x", "z"]

OrderBy([9,8,7,6,5,4,3,2,1], _%3)
Returns:
[9,6,3,7,4,1,8,5,2]

OrderBy([9,8,7,6,5,4,3,2,1], _%3 + _/30)
Returns:
[3,6,9,1,4,7,2,5,8]
OrderByDescending (array)
  1. Array to order
  2. Order expression
Result is same as in the OrderBy function, except the order is reverse.
OrderByValue (array)
  1. Array to order

Orders the given array using the natural order of items, for example numbers it's the increasing order, and for strings it's text ordering.

OrderByValue(["a", "x", "b", "z", "n", "l", "a"])
Return:
["a", "a", "b", "l", "n", "x", "z"]

OrderByValueDescending (array)
  1. Array to order

Result is same as in the OrderByValue function, except the order is reverse.

DateTime and TimeSpan functions

Function Parameters Description
DateTime
  1. Year (1-9999) (Integer)
  2. Month (1-12) (Integer)
  3. Day (>= 1) (Integer)
  4. Hour (>= 0) (Integer)
  5. Minute (>= 0) (Integer)
  6. Second (>= 0) (Integer)
  7. Millisecond (>= 0) (Integer)

Creates a new DateTime object. Only the first (year) parameter is mandatory.

Examples:

DateTime(2017)
Returns: A datetime for 1st January 2017 at 0:00:00.

DateTime(2017, 5)
Returns: A datetime for 5th January 2017 at 0:00:00.

DateTime(2017, 5, 6, 13, 34, 56, 123)
Returns: A date time object for 6th May 2017 at 13:34:56.123.
DateTimeFromTicks
  1. Number of ticks (Integer)

Creates a new DateTime object from an integer representing ticks. A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond, or 10 million ticks in a second.

Examples:

DateTimeFromTicks(DateTime(2018, 5, 6, 13, 34, 56, 123).Ticks)
Returns: A date time object for 6th May 2018 at 13:34:56.123.
TimeSpan
  1. Days (Integer)
  2. Hours (Integer)
  3. Minutes (Integer)
  4. Seconds (Integer)
  5. Milliseconds (Integer)

Creates a new TimeSpan object. Only the first parameter (number of days) is mandatory. By default, other parameters are assumed to be zero.

Examples:

TimeSpan(1)
Returns: Time span for the duration of 1 day.

TimeSpan(12,3,4,5,6)
Returns: Time span for the duration of 12 days, 3 hours, 4 minutes, 5 seconds and 6 milliseconds.
TimeSpanFromTicks
  1. Number of ticks (Integer)

Creates a new TimeSpan object from an integer representing ticks. A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond, or 10 million ticks in a second.

Examples:

TimeSpanFromTicks(TimeSpan(12,3,4,5,6).Ticks)
Returns: A time span object representing 12 days, 3 hours, 4 minutes, 5 seconds and 6 milliseconds.

Array functions

Function Parameters Description
Array
  1. Item 1 (Object)
  2. Item 2 (Object)
  3. ...

Creates a new array where the provided parameters are items of the array. There can be any number of parameters. Note: arrays can also be created using [] syntax.

Examples:

Array(1, 2, 3)
Returns: An array having three elements which are 1, 2 and 3.
Also following syntax can be used: [1, 2, 3]

Array()
Returns: An empty array.
Concat (Array)
  1. Hierarchical object

Concatenate multiple arrays together into one. Returns a single array which contains all the arrays given as parameter concatenated together in the same order they were given. If a parameter is not an array, it will be converted into an array having only the given element.

Examples:

Concat(1, [DateTime(2017), 3], [4, "foo"], "bar")
Returns: [1, DateTime(2017), 3, 4, "foo", "bar"]
ConcatTop (Hierarchical object)
  1. Hierarchical object

Concatenate the topmost arrays in a given hierarchical object. Returns a new hierarchical object with the contents of the topmost level concatenated and removed.

Examples:

ConcatTop([ 0, [1,2], [3], [4,[6,7]] ])
Returns: [1, 2, 3, 4, [6, 7]]

ConcatTop([ [1,[2,3]], [4,[6,7]] ])
Returns: [1, [2, 3], 4, [6, 7]]
CountTop (Array)
  1. Hierarchical object

Get the number of elements in the topmost level array of a in a given array or hierarchical object.

Examples:

CountTop([ 0, [1,2], [3], [4,[6,7]] ])
Returns: 4

CountTop([[1,[2,3]],[4,[6,7]]])
Returns: 2
GetAt (Object)
  1. Index (Integer)
  2. Array

Returns element at given index from the beginning of the array. The first item has index zero. If given a hierarchical object, returns the element at given index of the root level array. Throws a calculation exception if the given index does not exist in given object or given object is not an array.

Examples:

GetAt(0, [1,2,3])
Returns: 1

GetAt(1, [[1, 2], [3, 4]])
Returns: [3, 4]

GetAt(1, [[[5, 6]], [[1, 2], [3, 4]]])
Returns: [[1, 2], [3, 4]]

GetAt(1, GetAt(1, [[[5, 6]], [[1, 2], [3, 4]]]))
Returns: [3, 4]
GetAtReverse (Object)
  1. Index (Integer)
  2. Array

Same as the GetAt function, except that the index is calculated from the end of the array.

In (Boolean)
  1. Array where to search the object

Function checks whether the current context object is in given array, and returns either true or false. Note that the searched object is not given as a parameter, but it's the context object for the function (see the examples).

Examples:

1.In([1,2,3])
Returns: true

[1].In([[1],2,3])
Returns: false

DateTime(2017).In([DateTime(2016), DateTime(2017)])
Returns: true

Count(eventLog.Events.TimeStamp.DateTime(_.Year).In([DateTime(2012)]).Where(_==true))
Returns: The number of events there are in the given event log that have time stamp for year 2012.
IndexOfSubArray (Integer)
  1. Optional object on which to operate
  2. Sub-array to search(array)
  3. Array from where to search the sub-array (array)

Returns the indexes of given sub-array (1. parameter) within the given array (2. parameter). If not given, the array in the current context object is used. Returns starting indexes of all the occurrences of given sub-array within given array. Examples:

[[1,2,3,4,1,2,5]].IndexOfSubArray([1,2])
IndexOfSubArray([1,2], [1,2,3,4,1,2,5])
Return: [0, 4]

[[1,2,3,4,1,2,5]].IndexOfSubArray([1,2,3,4,5])
Returns: []

[[1,2,3,4,1,2,5],[3,4],[0,1,2,3]]:IndexOfSubArray([1,2])
Returns:
[
  HierarchicalArray([1,2,3,4,1,2,5], [0,4]),
  HierarchicalArray([0,1,2,3], [1])
]
StringJoin (String)
  1. Separator between joined parts (String)
  2. Array of items to join (Array)

Joins the given array of values (converted to strings) by using given separator into a single string. If given a hierarchical object, applies the function as described in at the level that is one level up from the leaf level. The depth of the result is one level less than the object that was given as parameter.

Examples:

StringJoin(", ", [1,null,"foo",DateTime(2017)])
Returns: 1, , foo, 01/01/2017 00:00:00

StringJoin(", ", [[1,2], [3,4]])
Returns: ["1, 2", "3, 4"]

Set functions

Function Parameters Description
Distinct
  1. Array or hierarchical object

Modify given array by filtering out all duplicate values leaving only distinct values in the input array into the result. If given a hierarchical object, applies the function at the level that is one level up from the leaf level.

Examples:

Distinct([1])
Returns: [1]

Distinct([1, 1])
Returns: [1]

Distinct([1, 1, 2, 2])
Returns: [1, 2]

Distinct([1, 1, 2, 2, "a", DateTime(2017), DateTime(2017), "b", DateTime(2016), "a"])
Returns: [1, 2, "a", DateTime(2017), "b", DateTime(2016)]
Intersect
  • First array
  • Second array
  • ...

Creates an intersection of multiple arrays. Returns a single array which contains an intersection of all the items in all the arrays given as parameter. If a parameter is not an array, it will be converted into an array having only the given element.

Examples:

Intersect([1, 2, "a", DateTime(2017), 5], ["a", 2, 3, DateTime(2017), 5], [DateTime(2017), "a", 2])
Returns: [2, "a", DateTime(2017)] 
Except
  • First array
  • Second array
  • ...

Creates an substract given items from an array. Returns a single array which contains all the elements that were in the first array that were not in any of the subsequent arrays. If a parameter is not an array, it will be converted into an array having only the given element.

Examples:

Except([1, 2, "a", DateTime(2017), 5, "b", 6], ["a", 2, 3, DateTime(2017), 5], [DateTime(2017), "a", 2, 6])
Returns: [1, "b"]
Union
  • First array
  • Second array
  • ...

Creates an union of multiple arrays. Returns a single array which contains an union of all the items in all the arrays given as parameter. If a parameter is not an array, it will be converted into an array having only the given element.

Examples:

Union([1, 2, "a", DateTime(2017), 5], ["a", 2, 3, DateTime(2017), 5], [DateTime(2017), "a", 2, "b"])
Returns: [1, 2, "a", DateTime(2017), 5, 3, "b"]

Loop functions

Function Parameters Description
For
  1. Iterated variable name (String)
  2. Initial value for iterated property (object)
  3. Iteration condition expression
  4. Next iteration step expression
  5. Expression to calculate iterated items

Iterates the given expression until the given condition is met, and returns the results of the iterated expressions for every iteration as an array.

Examples:

For("i", 0, i < 4, i + 1, i)
Returns: [0, 1, 2, 3]

For("x", 0, x < 3, x + 1, For("y", 0, y < 3, y + 1, StringJoin(",", [x, y]))
Returns: [["0,0", "0,1", "0,2"], ["1,0", "1,1", "1,2"], ["2,0", "2,1", "2,2"]]

For("i", 0, i < 4, i + 1, DateTime(2010 + i))
Returns: [DateTime(2010), DateTime(2011), DateTime(2012), DateTime(2013)]

For("str", "a", str != "aaaaa", str + "a", str)
Returns: ["a", "aa", "aaa", "aaaa"]
ForEach
  1. Variable to repeat (String)
  2. Array to repeat
  3. Expression to calculate repeated items

Repeats the given expression as many times there are items in the given array. Item in the array is available as the given variable in the expression. Examples:

ForEach("i", [1,2,3], "Value is: " + i)
Returns:
Value is: 1
Value is: 2
Value is: 3

Returns:
aa
bb
cc

Results: Creates expression variable variables like "c<casename>" for every case in the model.

ForEach("item", EventLogById(1).Cases, Let("c" + item.Name, item))
ForEach("myVariable", ["a", "b", "c"], myVariable + myVariable)
NumberRange
  1. Start (Number)
  2. End (Number)
  3. Interval (Number)

Creates an array of numbers within given range with the given interval. Interval parameter is optional, and by default it is one.

Examples:

NumberRange(1, 3)
Returns: [1, 2, 3]

NumberRange(1, 3, 0.5)
Returns: [1, 1.5, 2, 2.5, 3]

NumberRange(1, 3, 0.8)
Returns: [1, 1.8, 2.6]
Repeat
  1. Number of times to repeat (Integer)
  2. Expression to repeat

Repeats the defined expression the defined number of times. Examples:

Repeat(3, "Repeat me!")
Returns:
"Repeat me!"
"Repeat me!"
"Repeat me!"

Repeat(1, 5)
Returns
5
TimeRange
  1. Start (DateTime)
  2. End (DateTime)
  3. Interval (Timespan)

Generates a timestamp array starting from the start timestamp with the defined interval, and ending when the end timestamp is reached. Note that this function only creates timestamps with equal durations, so it's not possible to e.g. create timestamps for each month (to do that, you can use the loops).

Generate datetimes starting from Monday 2017-01-01 and ending to Monday 2017-12-31 including all Mondays between them:
Timerange(Datetime(2018,1,1), Datetime(2018,1,1), Timespan(7))

Recursion functions

Function Parameters Description
Recurse
  1. Expression to call recursively
  2. Stop condition expression
  3. Maximum depth (Integer)

Evaluates the given expression recursively until given condition or recursion depth is met. The function returns all the traversed objects in a single array. When the stop condition expression evaluates to false, it will stop the current recursion without including the false evaluated object into the result. Default stop condition is !IsNull(_). The default maximum depth is 1000.

Examples:

(1).Recurse(_ + 1, _ < 5)
Returns: [1, 2, 3, 4]

event.Recurse(NextInCase)
Returns: An array of all the events following given event inside the same case.

event.Recurse(NextInCase, Type.Name != "Invoice")
Returns: An array of all the events following given event inside the same case until event whose type name is "Invoice", which will itself not be included into the result.

event.Recurse(NextInCase, Type.Name != "Invoice", 2)
Returns: An array of all the events following given event inside the same case until event whose type name is "Invoice" or until the recursion depth of 2 has been reached, which will itself not be included into the result.
RecurseWithHierarchy
  1. Expression to call recursively
  2. Stop condition expression
  3. Maximum depth (Integer)

Evaluates the given expression recursively until given condition or recursion depth is met. The function returns the traversed object hierarchy. When the stop condition expression evaluates to false, it will stop the current recursion without including the false evaluated object into the result. Default stop condition is !IsNull(_). The default maximum depth is 1000.

Examples:

[1,2].RecurseWithHierarchy([1,2], false, 2)
Returns: [1:[1:[1,2],2:[1,2]],2:[1:[1,2], 2:[1,2]]]

(1).RecurseWithHierarchy(_ + 1, _ < 5)
Returns: 1:[2:[3:[4]]]

RemoveLeaves(eventLog.Flows:From.Where(IsNull(_))).To.RecurseWithHierarchy(OutgoingFlows.To, !IsNull(_), 2)
Returns: A hierarchy consisting of all the starter events of given event log and recursively all the event types reachable from them via flows until depth of 2 is reached.
RecursiveFind
  1. Expression to call recursively
  2. Find condition expression
  3. Stop condition expression
  4. Maximum depth (Integer)
  5. Continue after finding (Boolean)

Evaluates given expression recursively until given condition or recursion depth is met. The function collects all the traversed objects that match the given find expression along the way. When the find condition expression evaluates to true for the current object, it causes the following:

  • Current object is added to the result array returned by the function call
  • If continue after finding is false, the recursion will not be continued on this branch

When the stop condition expression evaluates to false, it will stop the current recursion without including the false evaluated object into the result. Default stop condition is !IsNull(_). The default maximum depth is 1000.

Continue after finding tells should the recursion be continued after a match has been found in the current branch.

Examples:

(1).RecursiveFind(_ + 1, _ == 100)
Returns: 100

eventLog.Cases:GetAt(0, Events).RecursiveFind(NextInCase, Organization=="Finance", !IsNull(_))
Returns: For each case, returns the first (by time) event whose organization equals to "Finance".

eventLog.Cases:Events.Where(Organization=="Finance")
eventLog.Cases:GetAt(0, Events).RecursiveFind(NextInCase, Organization=="Finance", true, true)
Returns: Both return for each case all events whose organization equals to "Finance".

Variable handling functions

Function Parameters Description
Def
  1. Function name (String)
  2. Variable 1 name (String)
  3. Variable 2 name (String)
  4. ...
  5. Function expression

Creates a new user defined function. Parameters starting from the second, are the parameters that user gives when calling the function. The last parameter is the expression to evaluate when the function is called. In that definition expression the named parameters are used. The created function is valid only within the current scope and all its child scopes.

Examples:

Def("Inc", "a", a + 1); Inc(2);
Returns: 3

Def("Add", "a", "b", a + b); [1, 2, 3].Add(_, 2);
Returns: [3, 4, 5]

Def("AddSelf", "b", _ + b); [1, 2, 3].AddSelf(2);
Returns: [3, 4, 5]

Def("Fib", "a", If(a < 2, 1, Fib(a - 1) + Fib(a - 2))); Fib(10);
Returns: 89
Let
  1. Variable 1 name (String)
  2. Variable 1 value (Object)
  3. Variable 2 name (String)
  4. Variable 2 value (Object)
  5. ...
  6. Expression to evaluate

Defines one or several user defined variables which can be used in the expression provided as the last parameter. Note that user defined variables cannot override existing properties.

Examples:

Let("var1", "Orange"); "Value is " + var1;
Returns: Value is Orange

Let("var1", "Orange", "var2", "Mango"); "Values are " + var1 + " and " + var2);
Returns: Values are Orange and Mango
Set
  1. Variable 1 name (String)
  2. Variable 1 value (Object)
  3. Variable 2 name (String)
  4. Variable 2 value (Object)
  5. ...

Set a value for a named variable. Can also be used to set several variable values at once. The variable to set must have been created in some visible scope by Let function. There can be any number of variable name and variable value pairs as long as the number of parameters is even number.

If the number of parameters was two, the result is just the value that was set for that single value. If the number of parameters is more than two, the result is an array of all the set values.

Variable
  1. Variable name (String)

Function to get a variable value. The function is needed when there are spaces in a variable name, because that variable cannot be referenced otherwise in the expressions.

Hierachical object functions

Function Parameters Description
FindRepeats
  1. Array
  2. Minimum repeated length (Integer)
  3. Longest repeat length (Integer)

Searches for repeating patterns in given array. Parameters:

  1. Array to search the patterns in.
  2. Minimum integer length of a repeat that can be returned by this function (default = 0).
  3. Boolean value indicating whether to return all the repeating patterns (true) or only the ones having the longest length (false) (default = false)

Returns an array of arrays indicating the repeating patterns and their positions in the array formatted as follows:

  • Every repeating pattern has its own entry in the top-level array.
  • Every repeating pattern item in the top-level array is formatted internally as an array consisting of:
    • An array constining the repeating pattern itself.
  • An array consisting of all the indexes from which this pattern was found to start from.
  • Allows overlapping patterns.
  • Results are sorted primarily by the length of the pattern and secondarily by the number of indexes the pattern was found in.

Examples:

FindRepeats([0, 1, 2, 0, 1, 2])
Returns: [
  [[0, 1, 2], [0, 3]],
  [[0, 1], [0, 3]],
  [[1, 2], [1, 4]],
  [[0], [0, 3]],
  [[1], [1, 4]],
  [[2], [2, 5]]
]

FindRepeats([0, 1, 2, 0, 1, 2], 0, true)
Returns: [[[0, 1, 2], [0, 3]]]

FindRepeats([1, "b", DateTime(2017), 1, "b", DateTime(2017)], 3)
Returns: [[1, "b", DateTime(2017)], [0, 3]]
Flatten
  1. Array or hierarchical object
  2. Include context object (boolean)

Collects all the actual leaf values from given array, array of arrays or hierarchical object and returns them in a single array. If given a hierarchical object, this function collects actual leaf values instead of leaf level values. Elements in the returned array are in the same order they were found when traversing the input object using depth first search.

When context object is included, should context objects in the internal nodes of a hierarchical object be also included into the result. Default is false.

Examples:

Flatten(1)
Returns: 1

Flatten([1, 2])
Returns: [1,2]

Flatten([[[1, 2],[3, 4]],[[5, 6]]])
Returns: [1, 2, 3, 4, 5, 6]

Flatten([[1, 2], 3])
Returns: [1, 2, 3]

Flatten([[1,2,3,4], null, [5], [1, null]])
Returns: [1, 2, 3, 4, null, 5, 1, null]

Flatten(["a":1, "b":2])
Flatten(["a":1, "b":2], false)
Returns: [1, 2]

Flatten(["a":1, "b":2], true)
Returns: ["a", 1, "b", 2]
RemoveLeaves
  1. Hierarchical object

Remove one level of hierarchy from a hierarchical object replacing all the bottom level hierarchical arrays with the context objects of the hierarchical arrays. Returns the given object with all the bottom level hierarchical arrays with the context objects of the hierarchical arrays.

Examples:

RemoveLeaves(["foo":1, "bar":2])
Returns: ["foo", "bar"]

RemoveLeaves(eventLog.Flows:From.Where(IsNull(_)))
Results: All the flows starting the cases in the event log.
ReplaceLeafValues
  1. Array or hierarchical object
  2. Variable name used in the iteration (String)
  3. Expression to get the result of each iteration
  4. Number of levels up from the leaf level to operate (Integer)

Replace all leaf values of given array or hierarchical object at given levels up from the leaf level with results of given expression.

Examples:

ReplaceLeafValues([1,2, null], "x", If(IsNull(x), null, x+1), 0)
Result: [2, 4, null]

ReplaceLeafValues([[[1,2],[2,3]],[[3,4],[4,5]]], "x", Flatten(x), 0)
Result: [[[[1],[2]],[[2],[3]]],[[[3],[4]],[[4],[5]]]]

ReplaceLeafValues([[[1,2],[2,3]],[[3,4],[4,5]]], "x", Flatten(x), 1)
Result: [[[1,2],[2,3]],[[3,4],[4,5]]]

ReplaceLeafValues([[[1,2],[2,3]],[[3,4],[4,5]]], "x", Flatten(x), 2)
Result: [[1,2,2,3],[3,4,4,5]]

ReplaceLeafValues([[[1,2],[2,3]],[[3,4],[4,5]]], "x", Flatten(x), 3)
Result: [1,2,2,3,3,4,4,5]
SliceMiddle
  1. Start index for the range to extract (Integer)
  2. End index for the range to extract (Integer)
  3. Levels up in the hierarchy (Integer)
  4. Array to slice

Extracts a continuous range of an array or hierarchical object. If given a hierarchical object, applies the function at the level that is specified levels level up from the leaf level.

Start index: Negative value means that the index is counting from the end of the array. If array does not have element at this given index, empty array is returned.

End index: not included into the extracted range. Negative value means that the index is counting from the end of the array. If array does not have element at this given index, all the elements to the end from the start index will be extracted.

Levels up: At which level of the hierarchical object are we operating (number of levels up from the leaf level). Should be at least 1 (since 0 level does not contain arrays).

Examples:

SliceMiddle(1, 2, 1, [[0, 1, 2, 3], [4, 5, 6, 7]])
Returns: [[1], [5]]

SliceMiddle(2, 4, 1, [[0, 1, 2, 3], [4, 5, 6, 7]])
Returns: [[2, 3], [6, 7]]

SliceMiddle(0, 1, 2, [[0, 1, 2, 3], [4, 5, 6, 7]])
Returns: [0, 1, 2, 3]

SliceMiddle(3, 5, 1, [0, 1, 2, 3, 4, 5, 6, 7])
Returns: [3, 4]

SliceMiddle(-3, -1, 1, [0, 1, 2, 3, 4, 5, 6, 7])
Returns: [5, 6]

SliceMiddle(3, -1, 1, [0, 1, 2, 3, 4, 5, 6, 7])
Returns: [3, 4, 5, 6]

Other functions

Function Parameters Description
Catch
  1. Expression to calculate
  2. Result if exception (Object)

Calculates the given expression and if any exceptions are thrown during the calculation, catches that exception and returns the given result. Note that this function does not catch any syntactical errors.

Examples:

Catch(1, 1234)
Returns: 1

Catch(undefined, 1234)
Returns: 1234

Catch([1,2].undefined, 1234)
Returns: 1234

Catch(EventLogById(-1), 1234)
Returns: 1234
Coalesce
  1. Object to coalesce
  2. Result if Null

Returns the second parameter if the first parameter evaluates to null or empty. If given a hierarchical object, applies the function at the leaf level. If the the given object is a hierarchical object, all its leaf level values are coalesced separately.

Examples:

Coalesce(0, 1)
Returns: 0

Coalesce(null, 1)
Coalesce(_empty, 1)
Coalesce(_remove, 1)
All return: 1

Coalesce([[null, 1], [null, null]], 3)
Returns: [[3, 1], [3, 3]]

Coalesce([[null, 1], 2], 3)
Returns: [[3, 1], null]

Coalesce([1, [null, 2], null], 3)
Returns: [1, [null, 2], 3]
ConformanceModelFromXml
  • BPMN XML (String)

Creates a new design process model (ConformanceModel object) from BPMN 2.0 XML string presentation.(BPMN 2.0 specification: https://www.omg.org/spec/BPMN/).

In the BPMN 2.0 XML file, the http://www.omg.org/spec/BPMN/20100524/DI section is not used by the ConformanceModelFromXml function, so it can be omitted to reduce data amount.

Note that the quotation marks need to be escaped if the BPMN 2.0 XML is provided as a literal in the expression.

Example:

Let("myConformanceMomdel", ConformanceModelFromXml("
  <?xml version=\"1.0\" encoding=\"UTF-8\"?>
    <bpmn:definitions xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:bpmn=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\">
    <bpmn:process id=\"Process_1\" isExecutable=\"false\">
    <bpmn:startEvent id=\"StartEvent_1\" />
    <bpmn:task id=\"Task_0y5w837\" name=\"abc\">
      <bpmn:outgoing>SequenceFlow_10mpkws</bpmn:outgoing>
    </bpmn:task>
    <bpmn:task id=\"Task_0c16r07\" name=\"def\">
      <bpmn:incoming>SequenceFlow_10mpkws</bpmn:incoming>
    </bpmn:task>
    <bpmn:sequenceFlow id=\"SequenceFlow_10mpkws\" sourceRef=\"Task_0y5w837\" targetRef=\"Task_0c16r07\" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id=\"BPMNDiagram_1\">
    ...
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
"))
EventLogById
  1. FilterId (Integer)

Returns EventLog object corresponding to the provided filter Id.

GetContext
  1. Hierarchical array

Returns the context of given hierarchical array. Returns the context object of the given hierarchical array. If the given object is not an hierarchical array, returns null.

Examples:

GetContext("a":1)
Returns: "a"

["a":1, "b":2, 2:3].GetContext(_)
Returns: ["a", "b", 2]

([1,2,3]:(_*2)).GetContext(_)
Returns: [1, 2, 3]

["a":1, 2, 3].GetContext(_)
Returns: ["a", null, null]
GetValueOfContext
  1. Context object
  2. Hierarchical array from which the value is searched

Returns the value of specified context object in given hierarchical array. Returns the the first value of specified context object in the given hierarchical array. If a match is found, the result will be an array. Returns _empty if the given key was not found.

Examples:

GetValueOfContext("bar", ["foo":1, "bar":2])
Returns: [2]

GetValueOfContext("bar", ["foo":1, "bar":2, "bar":"second"])
Returns: [2]

GetValueOfContext("test", ["foo":1, "bar":2])
Returns: _empty
ModelById
  1. ModelId (Integer)

Returns Model object corresponding to the provided model Id.

If
  1. Condition expression
  2. True expression
  3. False expression

Evaluates the condition expression and if it's true, returns the value of the second parameter. Otherwise returns the value of the third parameter. Always evaluates only either the second or the third parameter, but never both.

Examples:

If(Now.Second % 2 == 0, "Even second", "Odd second")
Returns:
"Event second" or "Odd second" depending on the time of the evaluation.

For("i", 0, i < 10, i + 1, i).If(_ % 2 == 0, _, _remove)
Returns:
[0, 2, 4, 6, 8]
NOTE: Is equivalent to: For("i", 0, i < 10, i + 1, i).Where(_ % 2 == 0)
IsNull (Boolean)
  1. Value to test (Object)

Return true if the provided value is null, otherwise returns false.

Where
  1. Condition expression
  2. False expression

Returns the context object if the given expression evaluates to true. Otherwise returns the second parameter. The second parameter is optional and it's by default EMPTY.

Examples:

[1,2,3,4].Where(_>2)
Returns: [3,4]

[1,2,3,4].Where(_>2, _+100)
Returns: [101, 102, 3,4]

[1,2,3].[_,_+1]
Returns: [[1, 2], [2, 3], [3, 4]]

[1,2,3].[_,_+1].Where(_>=3)
Returns: [[], [3], [3, 4]]

[1,2,3].[_,_+1].Where(_>=3, _remove)
Returns: [[3], [3, 4]]