Hello!
I try to use the search for users action and I want to get the first business phone of the first result only. I would prefer to avoid getting a for each. I tried a lot of different way to type an expression to get it with no success. I tried other values as well such as Mail with no success either...
I get this error :
Can you help me out please?
if(empty(items('Apply_to_each')?['body/businessPhones']?[0]),'N/A',
first(items('Apply_to_each')?['body/businessPhones']?[0])
)
I'm not done with your video but I found the answer at 2:45
Here is the formula that returns the first business phone of the first user found :
outputs('Search_for_users_(V2)')?['body/value']?[0]['BusinessPhones'][0]
Thank you very much!
Thank for the reply. My formula is :
outputs('Search_for_users_(V2)_2')?['body/value']?['BusinessPhones']
I see a part of yours with a ")" after ['body/value']. Where is the beginning of the parenthesis? I'm looking at your video right now so maybe I will find the answer there but while watching I thought I should ask here just in case.
@Volt26 The first() function should be used with the value dynamic content returned from the Search for users (V2) action.
When you run a test, it'll return the first user.
From that you can adjust your expression and add:
?['BusinessPhones']
Run a test.
Take a look a this YT Tutorial I recently uploaded: 3 Mistakes YOU 🫵 are Making with the Apply to Each Action in your Microsoft Power Automate Flow
In this video tutorial I’ll go over how to avoid these common mistakes when using the Apply to Each action in a Power Automate flow:
1️⃣ Looping through a Single Item
2️⃣ Creating Unnecessary Nested Loops
3️⃣ Looping through an Unfiltered Array
At the end of the video I share a few helpful insights when it comes to using the Apply to Each action in your flow.
I'll also cover:
✅ How to avoid the Apply to Each action with a single item array
✅ How to use the item() function to access dynamic content in an array
✅ How to prevent unnecessary nested Apply to Each action loops
✅ How to use the Select action
✅ How to convert an array to a string with the Select action
✅How to use the Filter Query field
✅ How to count the number of items in an array
✅ How to use a condition control
✅ How to use the concurrency control
✅ How to set a top count
✅ How to use Compose actions for troubleshooting
Hope this helps!
If I helped you solve your problem—please mark my post as a solution ✅. Consider giving me a 👍 if you liked my response! If you're feeling generous— ☕️ Buy me a coffee: https://www.buymeacoffee.com/acreativeopinion |
Michael E. Gernaey
566
Super User 2025 Season 1
David_MA
516
Super User 2025 Season 1
stampcoin
492