List Functions

  • fn.group_by_larger_than_count: Returns either a list of instance names or dictionary instance names with count values, given parameters:
    • model type
    • model attribute
    • greater than an input numeric value of the attribute
    • specified search direction in hierarchy: up or down
  • fn.list_index: Return a specified item from a list. Zero is the first item.
  • fn.list_index_item: Return the position of item in list.
  • fn.list_count: Return the number of items in a list. Note that if the list is known and empty, the count is 0, but if the list is not known, then the count is 1, because the returned message string count is 1.
  • fn.list_count_item: Return the number of times item is in a list.
  • fn.list_in: Return true or false if item is in a list or not.
  • fn.list_contain: Return true or false if item is a substring of an input context
    or is in a list or not.
  • fn.list_append: Returns a list with item appended.
  • fn.list_pop: Return the last item of the list.
  • fn.list_insert: Return a list with item inserted at position.
  • fn.list_insert_no_dup: Return a list with item inserted at position and all duplicates ignored.
  • fn.list_remove: Return a list with all instances of item or list of items removed.
  • fn.list_remove_dup: Return a list with all instances of item or list of items removed, including duplicates.
  • fn.list_remove_nulls: Return a list with all null instances in a list of items removed.
  • fn.list_reverse: Return a list that is the reverse of a given list.
  • fn.list_extend: Return a list that is an extension of list 1 with list 2.
  • fn.list_extend_no_dup: Return the concatenation of list1 and list2, ignoring duplicates.
  • fn.sequence: Return a sequence of numbers running from the first value to the second value, optionally padded with zeroes to be the length of a third value.
  • fn.list_set_symdiff: Given two lists as input, return the list of items that are not common to both lists.
  • fn.list_sort: Return a sorted list; by ascending (A) or descending (D) order.
  • fn.one: Return a single result from a list. This is used to convert a single element list to a string.

    If fn.one is called with a string, it returns the string unchanged. The string can be a macro that might get the value of another attribute from a context, such as input.some_variable.

  • fn.as_list: Return a string result as a list. If fn.as_list is called with a string, it returns a list. Again, abc could be a macro that resolves to the value of an attribute in its context.
  • fn.list_empty: Returns an empty list
  • fn.list_set_intersect: Given two lists, return the intersection as a list.
  • fn.list_set_union: Given two lists, return the union as a list.
  • fn.list_set_left: Given two lists, return a list of items in the left list only.
  • fn.list_set_right: Given two lists, return a list of items in the right list only.
  • fn.list_filter_fields: Given a model name, two field names, hierarchy PKID and a list of field values from one of the fields, return the list of values from the other field. The hierarchy PKID parameter must be passed in as a PKID of the hierarchy node.
  • fn.flatten_list_of_lists: Given a list of lists, return a single, flattened list.
  • fn.modulo_list: Given a list and divisor, return a modulo list: list items that leave no remainder after divided. The input list is typically a directory number list and the divisor is an E164 range.
  • fn.get_tvpair_list: Given an input list of dictionaries containing repeated pairs of equal type and a title-value mapping of these pairs, return a list of objects of these pairs where the pairs are mapped to title and value pairs that can for example be shown in a GUI rule in a choices drop-down list on a GUI form.
Example Output

Context hierarchy: sys, list of more than 1 of iso_country_code in data/Countries, search down

  • display as dictionary:
{{ fn.group_by_larger_than_count data/Countries,
                                 iso_country_code
                                 down, 1, dict }}
  • display as list:
{{ fn.group_by_larger_than_count data/Countries,
                                 iso_country_code
                                 down, 1, list }}
[
 {
  "iso_country_code": "AUS",
  "count": 2
 },
 {
  "iso_country_code": "CHN",
  "count": 2
 }
]



[
 "AUS",
 "CHN"
]
{{fn.list_index 2, data.Countries.country_name}}
“Canada” if this is the third item.
MACRO1={# fn.sequence 40, 43 #}

{{ fn.list_index_item 42,macro.MACRO1 }}
2
{{fn.list_count data.Countries}}



{{fn.list_count input.does_not_exist}}

{{fn.list_count non_existant_namespace.does_not_exist}}
25 if the
list has
25 items.

0

1
MACRO1={# data.Countries.international_access _prefix #}


{{ fn.list_index_item 00,macro.MACRO1 }}
19
{{fn.list_in 'AUS', data.Countries.iso_country_code}}


{{fn.list_in 'AUZ', data.Countries.iso_country_code}}
true


false
{
    "input": {
        "list": [
            "AUS",
            "BHR"
        ],
        "key": "aaAUZa"

    }
}
{{fn.list_contain 'AUS', input.list }}


{{fn.list_contain 'AUZ', input.key }}
true


true
MACRO1={# fn.sequence 40, 43 #}

{{fn.list_append 999, macro.MACRO1 }}
['40', '41',
 '42', '43',
 '999']
MACRO1={# fn.sequence  40, 43 #}

{{fn.list_pop macro.MACRO1}}
"43"
MACRO1={# fn.sequence  40, 43 #}

{{fn.list_insert 1, 999, macro.MACRO1 }}
['40', '999',
 '41', '42',
 '43']
MACRO1={# fn.sequence 40, 43 #}

MACRO7={# fn.sequence  39, 41 #}

{{fn.list_insert_no_dup  macro.MACRO1, macro.MACRO7}}
['40','41',
 '42','43',
 '39']
MAC1={# fn.sequence 40,43 #}
MAC7={# fn.sequence 40,41 #}
MAC3={{fn.list_insert 1,43,macro.MAC1 }}


{{fn.list_remove 43,macro.MAC3 }}


{{fn.list_remove macro.MAC7,macro.MAC1 }}
['40','41',
 '42']

['42','43']
{"pwf": {
 "my_list": [1, null, 2,"test", 3, null]
 }
}


{{ fn.list_remove_nulls pwf.my_list }}
[1,2,"test",3]

Given the following list is the result of the regex for iso_country_code:

{# data.Countries.iso_country_code |
   iso_country_code:/AU/ #}



{# fn.list_remove_dup data.Countries.iso_country_code
   iso_country_code:/AU/ #}
['AUS','SAU',
  'AUS','AUS']
['AUS','SAU']
MACRO1={# fn.sequence 40, 43 #}

{{fn.list_reverse macro.MACRO1}}
['43','42',
 '41','40']
MACRO1={# fn.sequence 40, 43 #}

MACRO9={# fn.sequence 50, 52 #}

{{fn.list_extend macro.MACRO1,macro.MACRO9 }}
['40', '41',
 '42', '43',
 '50', '51',
 '52']
MACRO1={# fn.sequence 40, 43 #}

MACRO8={# fn.sequence 42, 45 #}

{{fn.list_extend_no_dup macro.MACRO1, macro.MACRO8 }}
['40','41',
 '42','43',
 '44','45']
{# fn.sequence 40, 43 #}


{# fn.sequence 110, 100, 4 #}
['40','41',
 '42','43']

['0110','0109',
 '0108',
 '0107','0106',
 '0105','0104',
 '0103','0102',
 '0101','0100']
MACRO1={# fn.sequence 40, 43 #}

{{fn.list_sort macro.MACRO1, D}}


{{fn.list_sort macro.MACRO1, Descending}}


MACRO5={# fn.sequence 110, 108, 4 #}


{{fn.list_sort macro.MACRO5, A}}
['43','42',
 '41','40']

['43','42',
 '41','40']

['0110','0109',
 '0108']

['0108','0109',
 '0110']
{{fn.one data.Countries.iso_country_code
  emergency_access_prefix:'112'}}


{{fn.one abc}}

A single result, e.g. ‘FRA’

'abc'
{{fn.as_list data.Countries.country_name | country_name:'China'}}

{{fn.as_list abc}}
['China']

['abc']
{{fn.list_empty}}
[]
MACRO1={# fn.sequence 40, 43 #}
MACRO2={# fn.sequence 41, 42 #}

{# fn.list_set_intersect macro.MACRO1, macro.MACRO2 #}
['41','42']
MACRO1={# fn.sequence 40, 43 #}
MACRO2={# fn.sequence 41, 45 #}

{# fn.list_set_union macro.MACRO1, macro.MACRO2 #}
['40','41',
 '42','43',
 '44','45']
MACRO1={# fn.sequence 40, 43 #}
MACRO2={# fn.sequence 41, 45 #}

{# fn.list_set_left macro.MACRO1, macro.MACRO2 #}
['40']
MACRO1={# fn.sequence 40, 43 #}
MACRO2={# fn.sequence 41, 45 #}

{# fn.list_set_right macro.MACRO1, macro.MACRO2 #}
['44','45']
MACRO1={# fn.sequence 40, 43 #}
MACRO2={# fn.sequence 41, 45 #}

{{ fn.list_set_symdiff macro.MACRO1, macro.MACRO2 }}
['40','44','45']
{
    "input": {
        "list": [
            "AUS",
            "BHR"
        ]
    }
}


{# fn.list_filter_fields data/Countries,
    8c0hfle2c0deab00da595101, iso_country_code,
    country_name,  input.list #}
[
  "Australia",
  "Bharain"
]
 {
     "input": {
         "args": [
             [
                 "AAA"
             ],
             [
                 "BBBB",
                 "CCCC"
             ],
             [
                 "DD"
             ]
         ]
     }
 }

{# fn.flatten_list_of_lists input.args #}
[
  "AAA",
  "BBBB",
  "CCCC",
  "DD"
]
 {
     "input": {
         "args": [
             [
                 "100",
                 "12000",
                 "13000",
             ]
     }
 }

{{ fn.modulo_list input.args,1000 }}
[
  "12000",
  "13000"
]
{
  "input": {
   "dataList" = [
         {
             "timeZoneCode": "10",
             "timeZoneName": "Africa/Bissau"
         },
         {
             "timeZoneCode": "100",
             "timeZoneName": "America/Noronha"
         },
         ...
         ...
      ]
   }
}

{{ fn.get_tvpair_list input.dataList,
   title:timeZoneName, value:timeZoneCode }}
[
  {
    "value": "10",
    "title": "Africa
              /Bissau"
  },
  {
      "value": "100",
     "title": "America
             /Noronha"
  },
 ...
 ...
]