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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Search for O365 user u...
Power Automate
Answered

Search for O365 user until it exist

(0) ShareShare
ReportReport
Posted on by 46

Hey guys, I been stuck on this for awhile. Basically, I want to create flow that where I create the account on-premises and then the flow continue only after the user is found in O365. I create a DO Until Loop to keep doing something until the account exist, but it never wait until the account exist.

 

M7r229_0-1664551160632.png

 

Categories:
  • srduval Profile Picture
    1,796 Moderator on at

    The problem is probably if it's not finding the the user, the apply to each doesn't get triggered as the "value" is empty. get rid of the apply to each. Under your first search for user, initialize a variable and set it to a value you expect to be populated if the user exists. Then setup your do until and have it be the variable equals a value you want.  then the do until action is searching for the user, and setting the variable value. Once the user exists, the variable will get set the correct value and your loop will end. You will also want to add a delay timer to the do until or you'll burn through the loop limit quickly. 

  • M7r229 Profile Picture
    46 on at

    Im still lost, can you throw a little diagram so I can get an idea. This Is what I got from your comment

    M7r229_0-1665892847643.pngM7r229_1-1665892920171.png

     

  • M7r229 Profile Picture
    46 on at

    Any suggestions?

  • srduval Profile Picture
    1,796 Moderator on at

    Here is a rough screenshot of how you could set this up. You have the right idea, but you can't interact with the search users directly as the apply to each won't run until it finds the user. So if you search for test user and test user doesn't exist it the flow won't process down to the do until as you have it now. Then after the do until in the screenshot below is where you want to build out the rest of the flow.

    Screenshot 2022-10-24 094058.png

  • M7r229 Profile Picture
    46 on at

    Thanks, I will give that a try and report back

  • M7r229 Profile Picture
    46 on at

    I actually just tried running this and it just kept searching and searching even though I put a user that already existed. As you see the account was true, but it should not keep searching if it was found to be true. It should stop and just continue to the next flow

     

     

    Screenshot 2022-10-26 140503.pngScreenshot 2022-10-26 140556.png

  • Verified answer
    carloxvii Profile Picture
    95 on at

    Try to add a condition to check if search for users returns an empty value. Check the one I did if it'll work.

    carloxvii_0-1666863039321.png

    carloxvii_1-1666863063164.png

    Then add your delay at the last part after the condition.

  • srduval Profile Picture
    1,796 Moderator on at

    You might need to adjust the do unit I typically don't like using boolean (true/false) as they don't always return the result you expect when testing for them. In this case I think it was being returned True as a String not a boolean, so if you replace the expression "True" with just the typed word True, make sure you match case. 

     

    @carloxvii suggestion should also help escape the loop when a user is found.

  • M7r229 Profile Picture
    46 on at

    Arghh. @srduval before posting my message I tried using just the string true and it didnt let me esscape.

     

    @carloxvii. It escapes it, but no matter if it true or false. The flow ends after one pass through regardless

  • srduval Profile Picture
    1,796 Moderator on at

    I'll build one on my end and see if I can replicate. In the meantime try testing for the length of the name or some other field and see if that properly escapes.

    @carloxvii idea should have worked strange the it didn't 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 299

#2
11manish Profile Picture

11manish 274 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 119

Last 30 days Overall leaderboard