Item vs Items in PowerAutomate

 

πŸ’‘ Meaning of items() in Power Automate

In Power Automate,
items() is a function that represents the current item being processed inside a loop, such as an Apply to each action.

Think of it like this πŸ‘‡
If you have a list of rows and Power Automate loops through them one by one —
items() refers to the single row currently being processed.


🧩 Example

Suppose:

Your “List rows” (List_rows_1) returns:

{ "body": { "value": [ { "fullname": "John Doe", "emailaddress1": "john@contoso.com" }, { "fullname": "Jane Smith", "emailaddress1": "jane@contoso.com" } ] } }

You then add an Apply to each action:

Apply to each: value = outputs('List_rows_1')?['body/value']

Inside this loop:

  • On the first iteration, items() =

    { "fullname": "John Doe", "emailaddress1": "john@contoso.com" } ```
  • On the second iteration, items() =

    { "fullname": "Jane Smith", "emailaddress1": "jane@contoso.com" } ```

🎯 Using items() Inside the Loop

You WantExpression
Full Nameitems('Apply_to_each')?['fullname']
Emailitems('Apply_to_each')?['emailaddress1']

If your loop name is something else (say Apply_to_each_2), use:

items('Apply_to_each_2')?['fullname']

🧠 Analogy

You can think of it like:

for each record in list_of_records: current_record = items()

So items() = the current record being processed in the loop.


Would you like me to show the difference between items() and item() (they’re similar but used in slightly different contexts)?

You said:
yes
ChatGPT said:

Perfect πŸ‘Œ — this is a subtle but important distinction in Power Automate.
Let’s break down the difference between item() and items(), when to use which, and why both exist.


⚖️ Difference Between item() and items()

FunctionUsed InMeaningExample Use
item()Inside a nested action (like inside a “Filter array”, “Select”, or “Apply to each”)Refers to the current record being processed in that specific loop or data operationitem()?['fullname']
items('LoopName')When referring to a specific loop’s current item from outside or nested inside another loopRefers to the current item of a specific “Apply to each” action by its nameitems('Apply_to_each')?['fullname']

🧩 Example 1 — Basic “Apply to each”

You have:

Apply to each: value = outputs('List_rows_1')?['body/value']

Inside the loop:

✅ Both work the same:

item()?['fullname']

or

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

However, Power Automate usually auto-generates the second version:

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

because it’s more explicit — it tells which loop it belongs to.


🧩 Example 2 — Nested Loops (Inner + Outer)

Let’s say you have two loops:

  • Outer Loop: Apply_to_each_Contacts

  • Inner Loop: Apply_to_each_Orders

Now you want to access:

  • The current Order → that’s from the inner loop

  • The current Contact → that’s from the outer loop

You wantExpression
Field from Order (inner loop)item()?['orderid']
Field from Contact (outer loop)items('Apply_to_each_Contacts')?['fullname']

✅ Here’s why:

  • Inside the inner loop, item() means “current order”.

  • To refer to the outer loop’s item (contact), you must use items('Apply_to_each_Contacts').


🧠 Analogy (Simple Mental Model)

for each contact in Contacts: for each order in Orders: // item() = current order // items('Apply_to_each_Contacts') = current contact

⚡ TL;DR Summary

Use CaseUse
Inside a single loop (not nested)item() or items('Apply_to_each') both fine
Inside nested loopsitem() → inner loop item; items('LoopName') → specific outer loop item
Outside of the loopOnly items('LoopName') works
Inside “Select” / “Filter array” / “Map”Use item()

Comments

Popular posts from this blog

πŸ” Dataverse + Azure Integration: Choosing Between Synapse Link and Microsoft Fabric

⚡ Example: Rate Limiting in Azure API Management

In-Process vs Isolated Process Azure Functions: What’s the Difference?