web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Trouble using an expre...
Power Automate
Unanswered

Trouble using an expression to avoid looping

(0) ShareShare
ReportReport
Posted on by 37

I have a Microsoft Form that returns a FirstName LastName value for one of the responses. My flow uses the "Search for Users V2" operation on this FirstName LastName to get the UserPrincipalName. 

bigfella_0-1653064271616.png

 

I want to use this UPN as the input for the next action, Get Manager (V2). The problem is that I guess the flow assumes there could be more than one user that matches in the Search User action and automatically tries to do a "For Each" if I use the UPN as dynamic content. 

bigfella_0-1653065040716.png

 

Since I know there will only ever be a single user returned in Search for User, I want to avoid the loop. I am trying to do this with an expression. For the input to Get Manager (V2), I use outputs('Search_for_users_(V2)')?['UserPrincipalName'], but this gives me an error: The 'inputs.parameters' of workflow operation 'Get_manager_(V2)' of type 'OpenApiConnection' is not valid. Error details: The resolved string values for the following parameters are invalid, they may not be null or empty: 'id'

I've also tried it formatted outputs('Search_for_users_(V2)')?'body/value/UserPrincipalName'] and outputs('Search_for_users_(V2)')?['value/UserPrincipalName']

 

Here is the raw output to Search for Users:

bigfella_1-1653064885840.png

 

Thanks in advance!!

 

Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    68,678 Most Valuable Professional on at

    Search for users will always return an array of users, even if there is only one.  You can use first() around the array to get the first record, then append ?['fieldname'] to the end of that in the expressions tab to get the UPN.  Something like this

    first(outputs('Search_for_users_(V2)')?['body/value'])?['UserPrincipalName']
  • CU03032103-0 Profile Picture
    37 on at

    Thank you so much, that did the trick!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 463 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 427 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard