Logic Apps: selecting the first element of an array

60 views Asked by At

Lets say you have an array and you want to take the first element of it. can you do this via expressions. In the below example im printing it in a teams chat.

enter image description here

1

There are 1 answers

0
Skin On BEST ANSWER

Yep, use the first() expression ... https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#first

Simply pass in your array and it will work ...

first(variables('Tactic'))

... or, use the more programmatic approach ...

variables('Tactic')[0]

... noting that array indexes start from 0.

Tip: Press the See more button next to the Collection node in the Expression window as you've shown.