Dictionary Utilities

Contains the following functions:

  • dictUtil_getKeys
    • Returns a list of keys in the dictionary. If it's a nested dictionary, only the keys of top-level dictionary are returned. This function is typically used in cases where you need to pass a dynamic set of key/values. You provide a dictionary, call this function to retrieve the keys and then loop through them with an a!forEach or similar construct.
  • dictUtil_merge
    • Merges a list of dictionaries into a single dictionary. Key names must be unique across all dictionaries in the list.
  • dictUtil_newByKeyVal
    • Creates a dictionary with a single entry. The entry contains a key/value pair. This function is used when the a dictionary needs to be created on the fly; for dictionaries where the key is known, you may create a dictionary using regular Appian syntax. There's currently no way to create a multi-entry dictionary directly but you may use this function several times and then combine dictionaries with the dictUtil_merge function. 

The following example retrieves a list of all values in top-level elements of a dictionary. It would return the list: {1,2}.

with(
  local!dict: ({x: 1, y: 2}),
  local!keys: dictutil_getkeys(local!dict),
  a!forEach(
    items: local!keys,
    expression:         
       index(local!dict, fv!item, {})
  )
)

Anonymous