cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ousselg
Frequent Visitor

Live update status of azure account

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

 

 

3 REPLIES 3
PowerRanger
Resident Rockstar
Resident Rockstar

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

 




​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
Frequent Visitor

@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
Frequent Visitor

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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,181)