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 Apps / Live update status of ...
Power Apps
Unanswered

Live update status of azure account

(0) ShareShare
ReportReport
Posted on by 53

Hi,

 

I started recently with building a onboarding and offboarding app for HR.

Onboarding is going well and I have a offboarding screen as well.

What I am missing now is deleting and resetting an account with PowerApps (haven't found a solution yet).

 

What I did is blocking a user.

It works but I want to have the live status of the value accountenabled and when I press the button I want the value to change. Somehow the account gets blocked but my variable show accountenable:true.....

 

I want to have the live status when you search for a user.

Sometimes when I press block user I see the little ants going and then everything works fine but sometimes I have to press the button couple times before anything happens.

I tried fixing this by adding a timer so azure has time to process it but that didn't to the trick.

 

I also added a label with this code:

 

If(Office365Users.UserProfileV2('txtusername-2'.Selected.Mail).accountEnabled,"Account not Locked","Account Locked")

 

That one works but only if I reload the app or search for another user first. I doesn't update in real time.

 

 

This is the screen with the code:

Ousselg_0-1645017144719.png

 

I am doing something wrong or is there a refresh label command I am not aware off...

 

 

Categories:
  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @Ousselg After you call AzureAD.UpdateUser you have to "refresh" the call for Office365.UserProfileV2. So it is not like that it will "always" listen to the userProfile. When calling Office365.UserProfileV2 you will get the "current" information as a result. If anything changes afterwards you will not notice.

     

    But as you do know when your App is updating the User in AzureAD you can just call Office365.UserProfileV2 again.

     

    What I would suggest is rewrite your formular like this

     

    Set(varUserEnabled,Office365Users.UserProfileV2('txtusername-2'.Selected.Mail).accountEnabled)

     

    You have to call this piece of code somewhere in your app....maybe on a Button OnSelect

     

    On your Label Text property use this:

     

    If(varUserEnabled,"Account not Locked","Account Locked")
    

     

    After you call your function to update the User you will call this piece of code again:

     

    Set(varUserEnabled,Office365Users.UserProfileV2('txtusername-2'.Selected.Mail).accountEnabled)

     

    This will update the variable again and therefore your label also.

     

    What you could check in addition is if AzureAD.UpdateUser has any return values. Not sure if it will return a boolean value or some User info...Depending on the return value something like this could also work

     

    Set(varUserEnabled,AzureAD.UpdateUser(........).accountEnabled)

     

    It is always worth checking what kind of return value a function has. This would then make a second call to Office365.UserProfileV2 obsolete.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • Ousselg Profile Picture
    53 on at

    @PowerRanger  Thanks for the answer.

     

    The return value is true or false (that's why I put the label there to see the current return value).

    Ousselg_2-1645036857196.png

     

    The value for VarUserEnabled is this:

     

    Ousselg_0-1645036347016.png

     

    This part 

    Set(varUserEnabled,AzureAD.UpdateUser(........).accountEnabled)  doesn't work as it can't find the .accountEnabled it seems:

     

    Ousselg_1-1645036669598.png

     

    And when should I use that part (if we get the formula to work)? I have a block user and unblock user button and can call a timer (and set it on timer end maybe?)

     

    p.s I did the timer part and it works, but only if I press the block or unblock button twice or three times....

    After the timer ends it does:

     

    Set(varUserEnabled,Office365Users.UserProfileV2('txtusername-2'.Selected.Mail).accountEnabled) ; UpdateContext({starttimerblock: false}) ; Reset('timer-block')

     

    and for the unblock

    Set(varUserEnabled,Office365Users.UserProfileV2('txtusername-2'.Selected.Mail).accountEnabled) ; UpdateContext({starttimerblock: false}) ; Reset('timer-unblock')

     

    Thanks

  • Ousselg Profile Picture
    53 on at

    With all the experts here somebody should be able to help right?

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 Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard