Skip to main content

How to Use the items() Function in Power Automate

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

Inside an Apply to each loop, items() gives you the item the loop is working on right now. Add ?['name'] and you get one of its properties. It's the expression you'll write most inside loops, and nested loops are where its loop name matters.

What It Does​

Microsoft's functions reference defines items() as the current item from each cycle of a for-each loop, used inside that loop. You name the loop:

Syntax
items('<loopName>')

The loop's name is the one you gave it, with underscores for spaces: a loop called For each list is For_each_list.

Prerequisites​

One item of the array, without its columns
{
"title": "RoleCompetencies",
"description": "Competencies and expected levels for each job title. Used by the Career Development Plan app.",
"noCrawl": false
}

Each item also has a columns array, used further down.

Read a Property​

To get the current list's title, add the property name after the item:

Expression
items('For_each_list')?['title']

['title'] reads the title property. The ? before it makes the read safe: if the item were empty, you'd get nothing instead of a failed step.

Add it with the expression editor (How to Add an Expression in Power Automate), here in the middle of Find the list's Uri:

The expression editor containing items('For_each_list')?['title'], beside the Find the list pane whose Uri ends in _api/web/lists?$filter=Title eq '

In Code view, an expression inside text sits in @{...}:

Uri in Code view
_api/web/lists?$filter=Title eq '@{items('For_each_list')?['title']}'&$select=Id

In the first pass, that's _api/web/lists?$filter=Title eq 'RoleCompetencies'&$select=Id, and in the second, the same with CompetencyResponses.

Nested Loops​

Each list has a columns array, and a second loop, For each column, goes through it. Inside the inner loop, both items are available:

ExpressionReturns
items('For_each_column')?['name']The current column's name
items('For_each_column')?['schemaXml']The current column's XML definition
items('For_each_list')?['title']The title of the list the columns belong to

That's why items() takes the loop's name. Microsoft's reference also has item(), with no name, which returns the current item of the loop it's in. With nested loops, naming the loop leaves no doubt.

Common Mistakes​

MistakeWhat happensDo this instead
Spaces in the loop nameThe expression doesn't find the loopUse underscores: For_each_list
Renaming the loop afterwardsExpressions keep the old nameName the loop before writing expressions
A property name that isn't in the dataYou get nothing backCopy the name exactly from your data

Troubleshooting​

SymptomLikely causeFix
The expression returns nothingThe property name differs from the dataCheck the item in the loop's run results
An error about the loop nameThe expression is outside that loopUse items() only inside its loop

FAQ​

What's the difference between items() and item()?​

items('Loop_name') reads the current item of the loop you name. item() reads the current item of the loop it's in. In a nested loop, items() lets you reach the outer loop's item too.

Can I use it in a condition?​

Yes, anywhere inside the loop: in a field, in a body, or in a condition's values.

Conclusion​

Inside a loop, items('Loop_name') is the current item, and ?['property'] reads one of its values safely. Use the loop's name with underscores, and in nested loops pick the loop whose item you mean.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.