Automation Action: List Operation
Create, update, sort and get single or all items from generic lists.
Create and update a list. This action enables you to create a generic list of values. You can then add to the list, delete, sort & search. You can then read single values or all values further in your Automation. Any number of separate lists can be created - with each list referenced by its name.
Each list must be given a Name. You cannot use the name of an existing %variable% as a list name. If you want to update the same list further in your Automation you would use the same name. Lists can contain any number of items (based on available memory).
Select the List Operation:
Create
Create a new list. A list must be created before any other operations can be used. If you re-create an existing list all existing items will be removed.
Specify the Of Type - this can be text, number or date. The Of Type setting determines how the list is sorted if you use the Sort operation.
Enable the Unique option to only allow unique values to be added to the list. If Unique is enabled then duplicate values cannot be added (an error will not be raised when duplicate values are added).
You can optionally initialize the created list with one or more Values. Values can contain %variables%.
You can also optionally add values contained in the Load From entry. A value will be added for each line contained in the %variable% specified.
Append
Append one or more values to the end of an existing list. Enter one or more Values to append. Values can contain %variables%.
Insert
Insert one or more values to an existing list. Specify the Index position where you want the values to be inserted. Index positions start at 1. If no index value is specified then the values will be inserted at the start of the list. The Index value can be a %variable%.
Delete
Delete a value at the specified Index position (starting at 1).
Get Value
Get a value at the specified Index position (starting at 1). The item value can be assigned to a %variable% from the Assign To list.
Get All Values
Get all values in the list and assign to the Assign To variable. The Return As defines how the list will be returned to the Assign To variable:
- Text : The list is returned as text with each value on a separate line.
- Json Array : The list is returned as a Json array.
- Markdown Table : The list is returned as a Markdown table.
- CSV : The list is returned as a CSV line with values separated by commas and quoted if required.
- HTML List : The list will be returned as a HTML unordered or ordered list.
Sort Ascending
Sort the list in ascending order.
Sort Descending
Sort the list in descending order.
Search For
Searches the list for a matching value (case insensitive) and assigns the index number to the Assign To variable (or blank if no match was found). Enter the value to search in the Search For entry.
Individual list values can be any text of any size. If the Of Type is set to number then the expected values should be numeric. If the Of Type is set to Date then the values should be dates or date+time. The date values are stored in yyyy-mm-dd hh:mm:ss format so they can be sorted.
The List Operation action has many uses. It can be used to create Json arrays. Where you add separate Json blocks or values to a list and then use the Get All operation with the Return As set to Json Array.
You can use the For Each action to loop through values in a list.
You can use a list name as a %variable% replacement. This will replace the %listname% with all values in the list (one per line).