Skip to main content

Notifications

Community site session details

Community site session details

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

 

  • v-yueyun-msft Profile Picture
    on at
    Re: Select values from nested array

    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

  • nwkhattak Profile Picture
    25 on at
    Re: Select values from nested array

    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.

  • Verified answer
    ManishSolanki Profile Picture
    15,085 Super User 2025 Season 1 on at
    Re: Select values from nested array

    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.

     

  • v-yueyun-msft Profile Picture
    on at
    Re: Select values from nested array

    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

     

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,552 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow