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 / IS it possible to use ...
Power Automate
Unanswered

IS it possible to use javascript in a power automate flow?

(0) ShareShare
ReportReport
Posted on by 18

So, I have finally got my stations in an array variable, and now I want to loop through and print the station names in the body of the email step. In the attached photo you can see the part of the email body I am trying to loop through things. I have not done this before so here is what I am trying

 

@{
                // Dynamically populate station names
                foreach(var stationName in Station Names) {
                    <div style="width: 17%; border-bottom: 2px solid rgb(111, 249, 57); padding-bottom: 7px; text-align: center;">
                        @{stationName}
                    </div>
                }
            }
 

Station Names is the variable that hold the station names, and of course stationName being what should be printing the station names. am I headed in the right direction?

 

email step.png
Categories:
I have the same question (0)
  • SamLed Profile Picture
    2,338 Moderator on at

    Hi @Bacon1,

     

    No JavaScript needed for what you want to accomplish, consider following flow design: 

    SamLed_0-1708002587518.png

     

    • I simulate your input data using first compose
    • In an Apply to each, I build div in a compose
    • Outside apply to each, I use an advanced Power Automate trick to get an array of DIVs by calling outputs of compose belonging to Apply to each and use join() to convert it to string. Power Automate won't propose it in Dynamic contents outside of the Apply to each, you have to write it as expression manually.

    Now, you've just to replace your "Station Names" variable  in your mail body by last compose outputs.

     

    [Edit] You can also achieve this without using loop:

    SamLed_0-1708005596066.png

     

    Select From: outputs('Data')

    Select map: item()?['Name']

     

    "No loop all DIVs" compose expression: 

    concat('<div style="width: 17%; border-bottom: 2px solid rgb(111, 249, 57); padding-bottom: 7px; text-align: center;">', join(body('Select_Names'), '</div><div style="width: 17%; border-bottom: 2px solid rgb(111, 249, 57); padding-bottom: 7px; text-align: center;">'), '</div>')

     

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 286

#2
David_MA Profile Picture

David_MA 256 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard