Skip to content

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.

Example list
An example List containing 3 items. Each item's position is shown at the left side.

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.

Monkedo provides multiple components to help you create and manage lists according to your automation needs.

The Create List component enables you to create lists in three distinct ways:

  1. Empty - This option creates an Empty List, useful when you need to populate it during the automation run.

  2. Repeat - This option generates a list with repeated values, which is helpful when you want initialize a list with the same item.

  3. 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.

Create List
Create List component

The 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).

Split Text component
Split Text component

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.

Split Text values

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.

The 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 Item
Get Item component

The 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.

Get Range
Get Range component

The 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.

Add Item
Add Item component

The 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.

Set Item
Set Item component

The Remove Item by Position component deletes a list item based on its position, returning two results:

  1. A new list without the removed item.

  2. 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.

Remove Item by Position
Remove Item by Position component

Merge Lists combines two lists into one and outputs the new list.

The 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.

The 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.

In 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:

List input expression

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:

List custom number expression

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.

List custom number expression example

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).

When 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.

Iterate List
Iterate List component

For more information you can look at the Iterators article.