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 / Select values from nes...
Power Automate
Answered

Select values from nested array

(0) ShareShare
ReportReport
Posted on by 25

 

Hi

I am creating HTML table from array to post in teams.

This is what my array contains.

[
{
"id": "333333333333333sssssssssssssss,
"receivedDateTime": "2024-01-23T15:25:11+00:00",
"hasAttachments": true,
"subject": "Subject Email 1",
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"lastModifiedDateTime": "2024-01-23T15:25:11+00:00",
"name": "Attachment File Name 1",
"size": 12739
},
{
"@odata.type": "#microsoft.graph.fileAttachment",
"lastModifiedDateTime": "2024-01-23T15:25:11+00:00",
"name": "Attachment File Name 2",
"size": 12739
}
]
},
{
"id": "333333333333333sssssssssssssss",
"receivedDateTime": "2024-01-23T15:24:50+00:00",
"hasAttachments": true,
"subject": "Subject Email 2",
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",,
"lastModifiedDateTime": "2024-01-23T15:24:50+00:00",
"name": "Attachment File Name 1",
"size": 12739
},
{
"@odata.type": "#microsoft.graph.fileAttachment",,
"lastModifiedDateTime": "2024-01-23T15:24:50+00:00",
"name": "Attachment File Name 2",
"size": 12739
}
]

 

I am feeding this array into "From" field of my create HTML Table. then using Header and values fields it works for below ones.

EmailReceiveTime = Item()?['receivedDateTime']

EmailSubject = Item()?['subject']

But I also want to include Attachment file names regardless of how many attachments are there with each email (in this example its 2 emails and each email have two attachments)

myflow.jpg

 

Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @nwkhattak 

    Thanks for your sample json for test first ! And according to your description, you want to show the attachments file names in your HTML Table.

    This is my test flow and the result in the email:

    vyueyunmsft_0-1706060695230.png

     

    (1)The Compose action is used to create the test data :

    vyueyunmsft_1-1706060723237.png

    (2)The "Initialize variable " action:

    vyueyunmsft_2-1706060742991.png

    (3)The "Apply to each" action:

    vyueyunmsft_3-1706060843004.png

    items('Apply_to_each')?['attachments']

    item()?['name']

    json(concat('[',items('Apply_to_each'),']'))
    Item()?['subject']

    Item()?['receivedDateTime']

    body('Select')?[0]

     

    (4)The last two actions:

    vyueyunmsft_4-1706060982078.png

    replace(replace(replace(body('Create_HTML_table_2'),'&lt;','<') ,'&#39;',string('''')) ,'&gt;' , '>')

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

     

  • Verified answer
    Manish Solanki Profile Picture
    15,167 Moderator on at

    Hi @nwkhattak 

     

    Another efficient way is to use expression to combine the values of attachment names. Here is an example.

     

    In this example, I have stored the input array in the compose action:

    ManishSolanki_0-1706073428042.png

    [
    {
    "id": "333333333333333sssssssssssssss",
    "receivedDateTime": "2024-01-23T15:25:11+00:00",
    "hasAttachments": true,
    "subject": "Subject Email 1",
    "attachments": [
    {
    "odata.type": "#microsoft.graph.fileAttachment",
    "lastModifiedDateTime": "2024-01-23T15:25:11+00:00",
    "name": "Attachment File Name 1",
    "size": 12739
    },
    {
    "odata.type": "#microsoft.graph.fileAttachment",
    "lastModifiedDateTime": "2024-01-23T15:25:11+00:00",
    "name": "Attachment File Name 2",
    "size": 12739
    }
    ]
    },
    {
    "id": "333333333333333sssssssssssssss",
    "receivedDateTime": "2024-01-23T15:24:50+00:00",
    "hasAttachments": true,
    "subject": "Subject Email 2",
    "attachments": [
    {
    "odata.type": "#microsoft.graph.fileAttachment",
    "lastModifiedDateTime": "2024-01-23T15:24:50+00:00",
    "name": "Attachment File Name 1",
    "size": 12739
    },
    {
    "odata.type": "#microsoft.graph.fileAttachment",
    "lastModifiedDateTime": "2024-01-23T15:24:50+00:00",
    "name": "Attachment File Name 2",
    "size": 12739
    }
    ]
    }
    ]

     

    Next, use expression to combine the attachments names for a list item in "Create HTML table" action:

    ManishSolanki_1-1706073534616.png

    join(xpath(xml(json(concat('{"root":{"item":',item()?['attachments'],'}}'))),'//name//text()'),', ')

    Pls use the same expression in your flow to get the desired result.

     

    Output:

    ManishSolanki_2-1706073594149.png

     

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

  • nwkhattak Profile Picture
    25 on at

    Thanks @v-yueyun-msft , @ManishSolanki Both.

    Manish's Solution saves me from Loop and adding extra steps. Wish i was able to figure out these long powerful expressions.

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi, @nwkhattak @ManishSolanki 

    Thanks for your response! Wow! It is amazing for the method @ManishSolanki  post . I have learned a lot from it !!😆

    Thanks both again!!!!

     

    Best Regards,

    Yueyun Zhang

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
David_MA Profile Picture

David_MA 250 Super User 2026 Season 1

#2
Expiscornovus Profile Picture

Expiscornovus 222 Most Valuable Professional

#3
Haque Profile Picture

Haque 174

Last 30 days Overall leaderboard