Maps, lists and arrays

Name Description Definition Samples
getListTotal Gets the total value of the requested list column. getListTotal(myListData, myColumn) {{ getListTotal .Data.WMSApi.InboundEfficiencyList “Duration” }}
getRoundedListTotal Gets the total value of the requested list column. Applies the roundTo logic. getRoundedListTotal(myListData, myColumn, decimals) {{ getRoundedListTotal .Data.WMSApi.InboundEfficiencyList “Duration” 2 }}
getRoundedAndHumanizedListTotal Same as getRoundedListTotal. Applies humanization (thousands comma separation) logic. getRoundedAndHumanizedListTotal(myListData, myColumn, decimals) {{ getRoundedAndHumanizedListTotal .Data.WMSApi.InboundEfficiencyList “Duration” 2 }}
isInStringArray Checks if element exists in array of strings. isInStringArray(“el”, strSlice) {{ isInStringArray “el” someStringArray }}
isInIntArray Checks if element exists in array of ints. isInIntArray(2, intSlice) {{ isInIntArray 2 someIntArray }}
indexOfStringSlice Returns index of element from array of strings. 0 if not found. indexOfStringSlice(strSlice, “el”) {{ indexOfStringSlice someStringArray “el” }}
addToIntArray Appends element to the array of integers ([]int). addToIntArray(intSlice, 2) {{ addToIntArray intArray 2 }}
addToStringArray Appends element to the array of strings ([]string). addToStringArray(strSlice, “el”) {{ addToStringArray stringArray “el” }}
arrayToString Converts an array of any type to string having elements separated by delim. string array elements must not contain spaces arrayToString(strSlice, “,”) string {{ arrayToString array “,” }}
setAnyMapValue Sets key-value entry to the map, supports any type. setAnyMapValue(map[string]any, string, any) map[string]any {{ setAnyMapValue $map “foo” 2 }}
in Helper function imitating regular loop for i:=0; i<10; i++. in(from, to) {{ range $i := in 0 10 }}

{{ $i }}

{{ end }}
inZeroPadding Same as in, but fills zeroes for smaller number sizes. E.g. in(from, to) {{ range $i := in 0 10 }}

{{ $i }}

{{ end }}
reverseStringArray Reverses string array ["one", "two"] => ["two", "one"] reverseStringArray(myStringArray) {{ reverseStringArray $array }}
getYearRange Similar to in but the last adjustment is done against the current year getYearRange(from, adjustCurrentYear) {{ range getYearRange 1800 10 }}
inZeroPadding Generate a range of string with given amount of zero paddings inZeroPadding(from, to, numberOfPads) {{ range inZeroPadding 1 12 2 }}
getSortedKeys Extracts keys from map then sorts them based on the passed order (asc or desc) and returns keys as []string getSortedKeys(map[string]any, “desc”) {{ getSortedKeys $m “desc” }}

Get totals notes

Note that getListTotal, getRoundedListTotal and getRoundedAndHumanizedListTotal functions under the hood return the value as a string. This means if you intend to use the value for further processing using the same helper functions then you would need to convert the values to required types first.

Example:

{{ $val := getRoundedListTotal .Data.WMSApi.InboundEfficiencyList "OpenTimestamp" 2 }}
{{ $val := toFloat $val }}
{{ $val := add $val 15.15756 }}
{{ roundToAndHumanize $val 2 }}

Also note that the function can be used with any integrated lists that contain an integer or float column.