Flow Automation: Counting List Items via Action
In a Flow Automation workflow, you can use the Count function action to count how many items are in a list, such as the orders returned by an earlier Batch query orders action. This lets you build conditions based on how often something happened — like how many times a customer has returned an order — without manually reviewing their order history.
This guide explains the fields available for this action and shows an example of using it to detect repeat return abuse.
| Note: Count function includes every item in the list, including duplicates. |
When to Use the Count Action
Use the Count function action when:
- You need to know how many items are in a list, such as how many orders a customer has returned.
- You want to compare that number in a condition further down the workflow.
- You need a numeric result to feed into later steps.
| Note: This article covers only the Count function action. For the complete workflow it's used in, see "Flow Automation: Building a Workflow to Detect Repeat Return Abuse." |
Field Descriptions
| Field | Description |
| List | The list to count, such as the orders returned by a Batch query orders action earlier in the same workflow. |
| Result Name | The name of the numeric result Flow generates, shown as Count (or count(2), count(3), and so on if you use more than one Count action in the same workflow). Reference this result in later conditions. |
Supported Actions
You can add the Count function action after any step that returns a list, including:
- Batch query orders
| Note: Currently, the Count function only supports lists returned by the Batch query orders action. |
Example Use Case
Here's a real-world example of using the Count function action — checking whether a customer has returned 2 or more orders in the last 6 months, before deciding whether to flag their new order:
- Trigger: Order created
- Action: Batch query orders — retrieve the customer's orders from the last 6 months, filtered to returned orders
- Action: Count — count the number of returned orders
-
Condition: Count is greater than or equal to 2
- If No: The workflow ends here — the order is not flagged
- If Yes: Continue to the Sum function action, described in "Flow Automation: Summing List Values via Action," to check whether the total refunded amount also matches a pattern of low-value, high-frequency return abuse