Looking for a way to get items count and then use a switch based on that

I am using node to get some filtered emails from Outlook. If the response rate is over 50 items it sometimes get’s an error (because of large data volume). So I added max 50 responses.

Now I need to repeat that process if there were exactly 50 items and end if items responded were less than 50.

I could use a switch node. But where I am struggling is how to get a number of items processed (look at the picture attached).

Any ideas?

Hi @gavia, welcome to the community!

To count the number of items a specific node has returned you can use an expression of {{ $input.all().length }}. This expression should work in any node, including the Switch node, like so:

Though if you only want to check if you have exactly 50 items (or less than 50 items) you might want to use the IF node instead of the Switch node. It only has two outputs and is therefore a bit easier to read in a workflow.

1 Like