Dataverse, Power Automate

Power Automate with Dataverse: “Apply to each” current item/previous item

Recently I was working on the solution and in the middle of the development discovered that I desperately need to refer to the previous item in the loop.

Let’s say, I iterate through the list of items I received via List Rows (Dataverse). I check a condition in the next iteration and based on the condition I need to do something with the item from the previous step. I know it sounds crazy. But I will explain why in the next post, promise. For this article it doesn’t really matter why.

I need to refer to the previous item. How do I do this? I Googled. I am very good at it. Yet I couldn’t find anything which could help me thinking. Then I did. I like to be grateful so this is the link:

https://sharepains.com/2018/12/18/filter-an-array-power-automate/

It’s a different topic but this is how I realized the exact steps I need to perform.

  1. I need a variable Current Item. I am looking at referring to multiple columns of the item, not just name or ID so I can’t simple store it in the string variable. I need type Object.

2. Inside “Apply to each” I need to populate it like this:

item()

3. To read columns, in my case it’s name, of the previous item (and many other columns which I can easily access now) It’s not a current item anymore, it’s a previous item. So if you are OCD something, rename it to something like Stored Item 😀:

variables('Current Item')?['name']

Super easy!

1 thought on “Power Automate with Dataverse: “Apply to each” current item/previous item”

Leave a comment