Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

Live update status of azure account



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:



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



Super User
Super User

@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




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:




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




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.


​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.
Helper I
Helper I

@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).



The value for VarUserEnabled is this:




This part 

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




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')



Helper I
Helper I

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

Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,198)