Find a first match in a list
Function: Find a first match in a list
This action helps you search through a list of items and find the very first item that meets specific criteria you define. It's useful when you have a collection of data and only need to identify one particular item based on its properties, rather than filtering the entire list.
Input
- List: This is the collection of items you want to search through. It could be a list of customers, products, tasks, or any other data.
- Filters: These are the rules you set to find your desired item. You can add one or more filters, each specifying:
- Attribute: The specific property of an item you want to check (e.g., "Product Name", "Order Status", "User Role"). The available attributes will depend on the type of items in your List.
- Operator: How you want to compare the attribute's value (e.g., "Equal", "Greater than", "Contains").
Equal: The attribute's value must be exactly the same as your specified value.Greater than: The attribute's value must be numerically larger than your specified value.Greater than or equal: The attribute's value must be numerically larger than or equal to your specified value.In: The attribute's value must be one of the values in a list you provide.Less than: The attribute's value must be numerically smaller than your specified value.Less than or equal: The attribute's value must be numerically smaller than or equal to your specified value.Not equal: The attribute's value must not be the same as your specified value.Not in: The attribute's value must not be one of the values in a list you provide.Contains: The attribute's value (text) must include your specified text.Contains \(ignore case\): The attribute's value (text) must include your specified text, without worrying about uppercase or lowercase letters.Starts with: The attribute's value (text) must begin with your specified text.Ends with: The attribute's value (text) must end with your specified text.
- Value: The specific data you want to compare against the attribute (e.g., "Laptop", 100, "Pending"). This field appears only when the selected operator requires a value.
Output
- Result: This is a variable that will hold the first item found in your list that matches all your specified filters. If no item matches, this variable will remain empty. By default, this variable is named
FOUND_MATCH, but you can change it.
Execution Flow
Real-Life Examples
Example 1: Finding a specific product by name
Imagine you have a list of products in your inventory and you need to quickly find the details of the first product named "Wireless Mouse".
- Inputs:
- List:
[ \{ "Name": "Wireless Mouse", "Price": 25, "Stock": 100 \}, \{ "Name": "Keyboard", "Price": 75, "Stock": 50 \}, \{ "Name": "Wireless Mouse", "Price": 30, "Stock": 75 \} ] - Filters:
- Attribute:
Name - Operator:
Equal - Value:
Wireless Mouse
- Attribute:
- List:
- Result: The
FOUND_MATCHvariable will contain:\{ "Name": "Wireless Mouse", "Price": 25, "Stock": 100 \}. The action stops after finding the first match.
Example 2: Identifying the first order above a certain amount
You have a list of customer orders and want to find the first order that has a total value greater than $500 to prioritize its processing.
- Inputs:
- List:
[ \{ "OrderID": "A101", "Total": 350, "Status": "Pending" \}, \{ "OrderID": "B202", "Total": 620, "Status": "Processing" \}, \{ "OrderID": "C303", "Total": 480, "Status": "Completed" \} ] - Filters:
- Attribute:
Total - Operator:
Greater than - Value:
500
- Attribute:
- List:
- Result: The
FOUND_MATCHvariable will contain:\{ "OrderID": "B202", "Total": 620, "Status": "Processing" \}.
Example 3: Locating the first active user in a specific department
Your application manages users, and you need to find the first user who is both "Active" and belongs to the "Marketing" department.
- Inputs:
- List:
[ \{ "Name": "Alice", "Department": "Sales", "Status": "Active" \}, \{ "Name": "Bob", "Department": "Marketing", "Status": "Inactive" \}, \{ "Name": "Charlie", "Department": "Marketing", "Status": "Active" \}, \{ "Name": "Diana", "Department": "HR", "Status": "Active" \} ] - Filters:
- Filter 1:
- Attribute:
Status - Operator:
Equal - Value:
Active
- Attribute:
- Filter 2:
- Attribute:
Department - Operator:
Equal - Value:
Marketing
- Attribute:
- Filter 1:
- List:
- Result: The
FOUND_MATCHvariable will contain:\{ "Name": "Charlie", "Department": "Marketing", "Status": "Active" \}.