web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Problem creating an ar...
Power Automate
Answered

Problem creating an array loop for modifying html text

(0) ShareShare
ReportReport
Posted on by 12

Trying to create a process flow that sends template emails for different stages of a process. 

 

User selects a list item and run a selected item flow. Selects the process stage from SharePoint for a selected item input. Then the flow takes the list item data and uses it to process various pieces of logic and spit out the appropriate email based on the data.  

 

Each of the emails content are currently hard coded. I need to avoid the maintenance on each of the emails steps and there are more than 30 of them. I need to allow the business users to update the email templates through a multi-line text field in a separate list and provide them with the place holder information for each of the fields. So they can adjust all their wording and templates. 

 

There is a video out there from Krishna Vandanapu which gave me the idea, his is based on Powerapps and only shows one field replacement.  

https://youtu.be/Ni-swoI_UKs

 

What I am having trouble with is in Powerautomate creating the required array and apply to each loop to look at each of the fields pulled from the SharePoint list. Then find the place holders in the Email template html from a variable and replace the place holders for each list item in the variable html. Effectively doing a find and replace. 

 

I gather it is probably an array like 

[

{

Key: Country, Value: United Kingdom

},

{

Key: Component, Value: Part1

}

]

 

I have about 60 plus fields currently so don't want to have to hard code those in emails as is currently the case. 

 

Any ideas or sugesstions or examples welcome 

 

Thanks

 

Categories:
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Philip_Worrell :

    Do you want to create a loop to replace the content in the body of the email in bulk?

    If so,I've made a test for your reference:

    My Flow:

    vbofengmsft_0-1624414575809.png

    vbofengmsft_1-1624414820577.png

    Reference Expression:

     

    replace(variables('EmailBody'),concat('[',items('Apply_to_each')?['Key'],']'),items('Apply_to_each')?['Value'])
     

    The Result

    vbofengmsft_0-1624414796628.png

    Best Regards,

    Bof

  • Philip_Worrell Profile Picture
    12 on at

    Thanks so much for that Bof.... 

    Saved me a ton of time. 

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 211 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 190

Last 30 days Overall leaderboard