Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
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

 

  • Philip_Worrell Profile Picture
    12 on at
    Re: Problem creating an array loop for modifying html text

    Thanks so much for that Bof.... 

    Saved me a ton of time. 

     

  • Verified answer
    v-bofeng-msft Profile Picture
    on at
    Re: Problem creating an array loop for modifying html text

    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

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1