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 / how Foreach items are ...
Power Automate
Answered

how Foreach items are referenced

(1) ShareShare
ReportReport
Posted on by 2
Hi,
I am new to power automate and trying to understand the logic behind the foreach references.
I tried the simple tutorial with the following flow:
 
List row one(spreadsheet) -> foreach (within that a "send mail").
 
It works just fine, I am just confused how does the mails "to" field know from items()?['Email'] (input using the flash icon)  that I am refering to the current foreach item and not just any item.
 
 
I tried putting another xlsx sheet infront of the first xlsx
List rows first(spreadsheet) -> List row one(spreadsheet) -> foreach (within that a "send mail").
 
And then within the mail "to" field selected again the email with the same result of showing items()?['Email'] (it did though put it into another foreach).
 
Why do i not have to write in the expression somehing like items(Foreach_current_item)?['Email']. And if I do, how do I get it, by just klicking?
 
Thanks!
 
Categories:
I have the same question (0)
  • Amardeep Raj Profile Picture
    74 on at
    Hi
     
    Please follow the correct syntax as mentioned below
     
    items('Foreach_current_item')?['Email']
     
    item()?['Email'] 
     
    for more details visit Reference guide for expression functions - Azure Logic Apps | Microsoft Learn

    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,963 Moderator on at
    Hi
     
    For looks, they are references via item() not items(), usually when you reference something inside its item, from outside its items()?['ColumnName']
     
    The internal is just a pointer reference to the current iteration, in the back end it knows what index its on and therefor automatically gives you the proper indexed value (remember its an array you are iterating through).
     
    If you wanted to specifically references a specific instance of the array it would be more like (and not in a loop)
     
    outputs('My_List)_Rows)_Action')?[body/value]?[0-HowManyInstancesYouHaveMinus-1]?['FieldName']
     
    Where the above is referencing a specific instance of the Outputs starting at index 0 of the outputs json body/value reference
     
    you only need to type the whole you, you asked about when you are referrencing it outside of itself
     
    Example (think of it like this)
     
    List Rows
     
    ForEach (outputs('List_Rows'))
    (
       Compose (grab a value) item()?['AColumnName']
       ForEach_1(items('ForEach')?['ArrayColumnInTheOutterForEach'] 
         
         Compose_1 = item()?['GrabsFromForEach_1Automatically']
         Compose_2 = items('ForEach')?['ArrayColumnInTheOutterForEach']
    )
     
    Thats how.
     
     Also to point out, there if you are using a Select or a Filter Array Action, they expect you to reference item() in your fields, NOT items() as even though you didn't specifically create a loop, soon as you added an Input, which is an Array of things, it simply internally tracks it as a set of things and therefor consider it the "only loop" and therefor uses item() not items()
     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 471

#2
11manish Profile Picture

11manish 246

#3
David_MA Profile Picture

David_MA 238 Super User 2026 Season 1

Last 30 days Overall leaderboard