Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

How to do a foreach in an json array and append some variable for each item?

I have created a flow. Inside this flow I have some json array like below. I would like to loop into this json array. For each item in this array I would like to append a variable.




[{"Date":"21-01-2018","Project":"Project 2","ProjectCode":"12100003","Breakdown":"Start","Status":"Hard","TimeFrom":"09:00","TimeTo":"23:55","Hours":"14.92"},{"Date":"22-01-2018","Project":"Project 3","ProjectCode":"12100004","Breakdown":"Start","Status":"Zacht","TimeFrom":"09:00","TimeTo":"17:00","Hours":"8.00"}]


I would like to have at the end some variable like this:


21-01-2018<br/>Project 2<br/>12100003<br/><br/>22-01-2018<br/>22-01-2018<br/>Project 3<br/>12100004


My target is to add this variable inside the approval task email body. I already using the "Apply for each" action on the json array. Who can tell me how to do this?

Community Support
Community Support

Hi @khalidinio,


Could you please share a screenshot of your flow's configuration?

Do you want to append the variable ('21-01-2018<br/>Project 2<br/>12100003<br/><br/>22-01-2018<br/>22-01-2018<br/>Project 3<br/>12100004') that you mentioned for each item within the json array?


I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a Variables-> "Initialize variable" action, Name set to JsonArray, Type set to Array and Value set to the json data that you provided.
  • Add a "Apply to each", input parameter set to JsonArray variable.
  • Within "Apply to each", add a Compose action, Inputs set to following formula:


addProperty(item(),'variable1','21-01-2018<br/>Project 2<br/>12100003<br/><br/>22-01-2018<br/>22-01-2018<br/>Project 3<br/>12100004')


Note: The addProperty() function returns an object with an additional property.


Image reference:17.JPG



The flow works successfully as below:19.JPG


More details about the addProperty() function, please check the following article and search for it:




Best regards,





Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the solution. It works! I make it work without the compose and addProperty tasks. I initialize a variable and append this variable in the apply for each.

Hi @khalidinio,


Do you need any other help?


Best regards,


Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Frequent Visitor

Great Solution , Thanks.

Helpful resources

Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Users online (2,086)