Skip to main content

Notifications

Community site session details

Community site session details

Session Id : AglqKAvN/gnfoIqEKFBKAB
Power Automate - Building Flows
Unanswered

Get value from an array

Like (0) ShareShare
ReportReport
Posted on 16 Jun 2023 06:33:14 by 77

Hello all,

 

in my case I have an array which contains several hundred objects.
Each object contains a name, email and a task.


With a select I collect all emails and then I go into an apply to each in which I use a union to only get the emails once.

I then filter the big array to check if the email is equal to the current apply to each item and if yes, I am writing an Email to the user, telling him how many tasks are within the array (using length).

 

So far, so good.

 

Now I would also like to pull the name from the array so that I can address the Mail correctly ("Hello [Name]").

I tried to use item(Filter_array)?['Name'], however, this is not working. The Filter array has the big array containing all objects as the input.

 

Any ideas how I can pull the name into the Mail?

 

Markus44_0-1686897081041.png

 

 

 

  • Paulie78 Profile Picture
    8,407 Super User 2025 Season 1 on 16 Jun 2023 at 12:17:59
    Re: Get value from an array

    I suggest you do it slightly differently. Run the union outside of the array, this will give you a unique list of names and email addresses. Then inside your loop you can easily access the name:

     

    Image of example flow here (for easier viewing)

    https://ibb.co/w4YTyWq

     

    Image:

    ForumSolution.jpg

     

    See if that method is helpful to you.

     

    Blog: tachytelic.net

    YouTube: https://www.youtube.com/c/PaulieM/videos

    If I answered your question, please accept it as a solution 😘

  • Markus44 Profile Picture
    77 on 16 Jun 2023 at 07:23:13
    Re: Get value from an array

    Hello @fchopo  and @KimBim 

     

    Thanks to both of you for replying so quickly!

     

    Seems like I did not explain my case clear enough, sorry for that!

     

    So the big array does not contain unique names. Many people appear several times as they have many tasks.

    Therefore, I am using the union function inside the apply to each which then only contains the emails.

     

    [
     {
     "Name": "Bob",
     "Email": "bob@mailexample.com",
     "Task": "Prepare the Excel sheet",
     "Importance": "High"
     },
     {
     "Name": "Will",
     "Email": "will@mailexample.com",
     "Task": "Update the presentation",
     "Importance": "Low"
     },
     {
     "Name": "Bob",
     "Email": "bob@mailexample.com",
     "Task": "Set up a meeting",
     "Importance": "Low"
     }
    ]

     

    This example shows that Bob has two tasks.


    So outside the apply to each I have a select collecting all emails from that array as this is the unique identifier.


    As I need to only send one mail per user, I need a union, which is what is used within the apply to each.

     

    In the following screenshot you can see the working flow.


    FilterArticles contains all objects
    Select Email filter out the email addresses ob the big array

    union within the apply to each outputs the unique addresses

    FilterMailCheck compares the big array with the current item

    HTML Table pulls additional information which is shown in the email

     

    All of this works.


    The only thing missing is the user name which I would like to use to personalize the Mail 🙂

     

    Markus44_0-1686899853126.png

     

    I hope it is better explained now, please excuse the confusion.

     

    Kind regards

    Markus

  • KimBim Profile Picture
    157 on 16 Jun 2023 at 07:00:17
    Re: Get value from an array

     

    Hello @Markus44,

    Your scenario is certainly a common one when working with arrays in Power Automate. If I understand your use case correctly, you're trying to access the 'Name' property within each item of your filtered array to personalize the emails.

     

    I believe the expression items('Apply_to_each')['Name'] should work in your case. This expression will access the 'Name' property of the current item in the 'Apply_to_each' loop.

    Also, based on your explanation, it seems like you are already using the Union() function to obtain unique emails. If so, you might not require the filter array action to filter emails. You can directly use items('Apply_to_each')['Email'] to fetch the email.

     

    Here's a simplified example:

    Hello @{items('Apply_to_each')['Name']},
     
    You currently have @{length(items('Apply_to_each')['Task'])} tasks.
     

    This should fetch the name of the current item in the loop, and the length function will return the number of tasks for the individual.

     

    Please try this approach and let me know if it works for your scenario or if you encounter any issues or if i did not understand the requirement correctly 🙂

    Apply_to_each.png

  • fchopo Profile Picture
    7,968 Super User 2025 Season 1 on 16 Jun 2023 at 06:59:05
    Re: Get value from an array

    Hi @Markus44 

    It seems you're in the right path. In Filter array you should use:

    - From: variable containing all the data

    - expression: item()['Email'] is equal to items('apply_to_each')

    Hope it helps!

    Ferran

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started