The item function is oftentimes misunderstood since it’s not common to be used, but it’s beneficial. For example, when you’re inside a repeating action, like the Apply to Each action, you will need to use the elements of an object, like the Title in a SharePoint List Row. But what about if you’re using an array? There’s no object inside.
Let’s check how it works.
It doesn’t need any parameters to work. It only needs to be inside a repeating action.
To understand it better, let’s create an array using the createArray function.
We have an array with 5 elements, so not let’s do an Apply to Each action to see the result.
Since it’s not an object, what should we put there? That’s where the item function comes into play. If you put,
item() you’ll be able to access individual items for each new element of the array.
Here’s the function.
And here’s the result.
As you can see, this may not be as useful to us, except if you’re doing some debugging (check “debug compose” below), so prefer to use the object reference instead of the item function.
The item function is only useful when there’s an array of elements. If it’s an object, you may still use it, but it’s a lot more efficient to select the one you want to use in the list.
Here are some things to keep in mind.
Once in a while, I like to use Compose action with elements to have a place where I can check the values. So, for example, I include, once in a while, Compose actions with references to objects like this:
It may look strange, but this is an excellent way to look at the “run history” and see the values before I do something with them. I call this a “debug compose”, and the item function can be used for this purpose. This way, you’ll have the array element or object and see the values in each position of the Apply to Each action, making debugging a lot simpler.
Only use it in arrays.
As shown above, you can get arrays from SharePoint’s Get Item Action, but that doesn’t mean that it’s helpful to us. You can then make the function more complex to get the value, but referring to the value is much more straightforward. Don’t complicate things that can be simple.
Back to the Power Automate Function Reference.