Today a short post, about the item vs items functions in Power Automate apply to each steps. When to use which one and why? The choice between the item function and the items function isn’t as clear cut as you may expect.
Apply to each in Power Automate
Table of Contents
When you create an apply to each step, you can select the Current item from the Dynamic content. Current item refers to the item that is being processed within the apply to each step as shown below. As the apply to each iterates through your list of items, the Current item always points at the item that the apply to each is working on.

Power Automate makes it easy to just select Current item from the Dynamic content and all is good! Until you looking under the hood of the Current item dynamic content. We will see that the following expression is used when we select Current item.
items('Apply_to_each')
Nothing complicated. Just make sure that you take the name of your apply to each and replace each space with an underscore.
Copy/Paste actions
But how about copying the action inside the Apply to each to another apply to each. As we want to replicate this step we might bump into a small issue
So we use the copy paste functionality in Power Automate and we can create a flow like this.

Now when we hit the save button, we will see the following error message.

The template validation failed: ‘The inputs of template action ‘Compose_4’ at line ‘1 and column ‘1575’ is invalid. Action ‘Apply_to_each’ must be a parent ‘foreach’ scope of action ‘Compose_4’ to be referenced by ‘repeatItems’ or ‘items’ functions.’.
Well that is annoying. You will have to remove the current item on the right. Then select the current item from the Dynamic content again.
Item to the rescue!
Rather than using items(…), we can use the item function.
Like with the select action where item() refers to the current item being processed. Within an apply to each step we can do the same thing using the item function.
In this case if we compare item vs items, we end up with more flexibility using the item function.

Now as the expression isn’t depending on the specific Apply to each step anymore, we can simply copy the step from one Apply to each to another apply to each and the flow will just save.
So the next time you select the Current item from Dynamic content you might want to consider using the expression editor and type item() instead.

As we have seen with copy/paste, where the items function causes some problems. If you drag and drop actions from one place to the other they will give similar issues. However, we will not see these issues when we use the item function instead.
FAQs
Can I always replace the items function with the item function?
Yes, you can if you don’t use nested apply to each steps. When you have nested apply to each steps, then item() can become confusing as it will refer to the most inner apply to each step.
Discover more from SharePains
Subscribe to get the latest posts sent to your email.
but how do i access a field if the apply to each is being used on a list? i’ve tried a bunch of stuff, with item() and without, but i always get expression is invalid, and i’ve been searching how to do this for more time than it would be reasonable for
HI Luca, Can you send me the expressions that you have tried? It sounds like a syntax issue.