List
The List data type in Monkedo allows you to group multiple items into a single structure where each item is identified by its position. The first item in a list has position 1, the second item has position 2, and so forth. Monkedo also supports negative positions for accessing items from the end of a list: -1 represents the last item, -2 represents the second-to-last, and so on. Lists can contain any data type and vary in length, even including no items at all, which is called an Empty List.
Lists are especially common when working with app components in Monkedo, as most data retrieval actions return information in list form. For example, a component retrieving product records would output a List containing each product as an item. Monkedo offers built-in components to create and manipulate lists, all of which can be found under the Action > List Operations category.
List Components
Section titled List ComponentsMonkedo provides multiple components to help you create and manage lists according to your automation needs.
Create List
Section titled Create ListThe Create List component enables you to create lists in three distinct ways:
Empty - This option creates an Empty List, useful when you need to populate it during the automation run.
Repeat - This option generates a list with repeated values, which is helpful when you want initialize a list with the same item.
Items - This option allows you to enter specific items, creating a list with predefined values, which can be useful when you know the exact contents you need in advance.
Split Text
Section titled Split TextThe Split Text component, found in the Text category, is useful for creating lists from a single string of text. This is particularly helpful when data is imported from external sources such as your computer or the Internet. The Split Text component can transform a text like "apple, banana, kiwi, orange" into a List by separating items based on a specified character or string, such as ", " (comma and space).
This operation results in a list of 4 items as shown below. The editor shows the only first 3 items but all items can be viewed by clicking the button below.
Additionally, if the text contains items on separate lines, you can split by line to produce a List of items, with each line as a separate item.
Get Item
Section titled Get ItemThe Get Item component retrieves a single item from a list based on its position. For example, providing position 1 will get the first item, while position -1 gets the last item.
Get Range
Section titled Get RangeThe Get Range component extracts a sublist from an existing List by specifying the starting and ending positions. This is useful for tasks like retrieving the first ten items from a large list, where the output is a new list containing only the selected items.
Add Item
Section titled Add ItemThe Add Item component allows you to insert an item at any position in a list. For instance, you can add an item to the end or start of a list or insert it at a specified position. This operation does not remove any existing items; instead, it shifts items as needed to accommodate the new addition.
Set Item
Section titled Set ItemThe Set Item component updates an existing list item at a specific position. If the specified position does not yet exist in the list, it will create it.
Remove Item by Position
Section titled Remove Item by PositionThe Remove Item by Position component deletes a list item based on its position, returning two results:
A new list without the removed item.
The item that was removed.
For instance, removing the item at position 2 from a list of fruits would produce a list without that item while also returning the removed item as shown below.
Merge Lists
Section titled Merge ListsMerge Lists combines two lists into one and outputs the new list.
Sort List
Section titled Sort ListThe Sort List component allows you to sort a list in either ascending or descending order, useful when working with lists of numbers or text data.
Filter List
Section titled Filter ListThe Filter List component creates a new list that includes only the items that meet a specified condition, removing all others. This is particularly useful when narrowing down data sets based on criteria.
Monkedo offers even more components for List operations, all of which are available under Action > List Operations.
Expressions
Section titled ExpressionsIn Monkedo, you can use Expressions to access specific items in a list directly, which can simplify your automation by reducing the need for an extra Get Item component.
When the expression box is open on a component input, a menu allows you to see and select items from the list by their position. Selected items will display in the expression box by their position, as shown below:
To access an item at a position that isn't shown in the listβsuch as items near the end of the list using negative positionsβyou can enter a custom position. Simply click the option shown below to add your own position:
After enabling custom entry, enter the position directly. For example, entering 1000
will get the 1000th item and entering -1
will get the last item in the list, as shown below. After entering the position, click Select.
Using Expressions to access list items keeps your automation more organized and allows you to quickly reference list items without additional setup. List items can be accessed in all expression types (Text, Math and Access).
Iterating Over Lists
Section titled Iterating Over ListsWhen you need to process each item in a list individually, you can use the Iterate List component from the Flow Control category. This component sequentially outputs each list item, running for each item in the list until the end. The Iterate List component is invaluable for automations that perform repetitive actions on each item in a list, such as sending notifications for each record or calculating totals.
For more information you can look at the Iterators article.