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

Notifications

Announcements

Community site session details

Community site session details

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

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:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard