cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Practices for retrieving data from Office365Users.MyProfile() once and using it through the PowerApp

I noticed that whenever I use Office365Users.MyProfile() function it makes calls every time I uses it, and I do use it quite a lot in my application (like on every screen few times). That slows down my app as every time it asks for same information and wait until it loads. I was wondering is it possible to call Office365Users.MyProfile() function once the App is launched and reuse that info through the app without calling it ever again (or keeping it while the users session is active so that it connects to Office365 network only once per user session). Is there any practices of how to create temporary variables which keep their record for individual sessions while the users is using the App?

 

I am looking for something like this:

On App Launch:

UsersProfile() = Office365Users.MyProfile();

And then instead of using Office365Users.MyProfile()

I could use UserProfile() instead which is local variable and does not connect to external data every time.

Any other tips for improving efficiency also welcome! Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: Practices for retrieving data from Office365Users.MyProfile() once and using it through the Powe

The best way for me is using Context Variables. Basicailly you would do is add in the OnVisible of the first screen something like:

UpdateContext({UserProfile: Office365Users.MyProfile()})

From then on in that screen you can bind Labels to UserProfile.Mail, or UserProfile.DisplayName, etc.

 

If you need the same data in another screen, then when calling Navigate you can pass the context using the third argument like:

Navigate(Screen2, ScreenTransition.Fade, {UserProfile: UserProfile})

Then in that screen you will have UserProfile as well.

 

Another option if you don't like passing the context across screens is collecting it into a Collection since those are global, however it will be tedious and not very performant to do LookUp formulas like: LookUp(Globals, Name = "Profile").Value.DisplayName

 

So I would recommend using Context Variables as above. We are looking at supporting Global variables that will allow you to do something similar and not require to pass them through Navigate, but that is still not available.

 

 

View solution in original post

1 REPLY 1
Highlighted
Power Apps
Power Apps

Re: Practices for retrieving data from Office365Users.MyProfile() once and using it through the Powe

The best way for me is using Context Variables. Basicailly you would do is add in the OnVisible of the first screen something like:

UpdateContext({UserProfile: Office365Users.MyProfile()})

From then on in that screen you can bind Labels to UserProfile.Mail, or UserProfile.DisplayName, etc.

 

If you need the same data in another screen, then when calling Navigate you can pass the context using the third argument like:

Navigate(Screen2, ScreenTransition.Fade, {UserProfile: UserProfile})

Then in that screen you will have UserProfile as well.

 

Another option if you don't like passing the context across screens is collecting it into a Collection since those are global, however it will be tedious and not very performant to do LookUp formulas like: LookUp(Globals, Name = "Profile").Value.DisplayName

 

So I would recommend using Context Variables as above. We are looking at supporting Global variables that will allow you to do something similar and not require to pass them through Navigate, but that is still not available.

 

 

View solution in original post

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,296)