cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

Refreshing SP list passed as context variable

Hi all

I have an app where I am passing SP List as a context variable (Navigate(ListScreen, None, {list:SPList}) to another screen (call it List Screen, just to avoid creating multiple screens for identical lists) and it works fine. But if I ammend an item, changes saved in SP List but not reflected if I go back to List Screen.

So is there any way to refresh'list' context variable when going back after updating an item?

Thanks  

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Refreshing SP list passed as context variable

Hi @RomanKorchak,

Based on the issue that you mentioned, I think a global variable (via Set() function) could achieve your needs.

I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the "Navigate" button to following:

Set(SPListVariable, 'YourSPList');
Navigate(ListScreen, ScreenTransition.None)

Set the OnVisible property of the List Screen to following:

Refresh('YourSPList');
Set(SPListVariable, 'YourSPList')

Then use the SPListVariable within your List Screen instead of Context variable.

Note: For your app's performance, when passing the app’s state from one screen to another, create or modify a global variable value by using the Set function instead of by using the Navigate and UpdateContext functions. Please check the following for more details:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/performance-tips#use-global-variables

 

More details about Refresh function, please check the following article:

Refresh function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: Refreshing SP list passed as context variable

You could always put a Refresh function in your OnVisible action of the form.

Or, you could refresh the list during at the place where you navigate back to the list screen.

(ex: Refresh(dataSource); Back(None)   or, if you are navigating  Refresh(dataSource); Navigate(listScreen, None)

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Helper IV
Helper IV

Re: Refreshing SP list passed as context variable

Thanks for your reply

But if SP list item is changed (item edited in app or shanged in SP) and I refresh context variable that set to SP list - it doesnt get changes. It only changes if I go back to main screen and from there go to List screen (Thats where List screen context variable is asigned SP list to be used on List Screen). Just Refresh(ContextVariable) doesnt seem to do the trick.

Any ideas for that?

Thanks 

Highlighted
Super User
Super User

Re: Refreshing SP list passed as context variable

No, not Refresh(contextVariable)  Refresh(dataSource)

 

Since you are trying to assign variables throughout to keep track of things, you will have to

1) Refresh the source, 2) Reassign your variables.

 

So in this case, you will do a
Refresh(dataSource); UpdateContext({whateverYourVariable:WhateverYourList})

 

The two do not connect automatically.  Changing one does not change the other.

 

If your lists are Galleries, You might want to consider using your list as the variable.

In other words - instead of creating a variable and then having to continually update it, instead put the logic to filter and select what you want for your Gallery in the Items property and then "consider" the Gallery your vairable.  Ex. Gallery1.  Then you can, when needed, do things with Gallery1.AllItems (for a collection of items in your "variable") and Gallery1.Selected (for a record of one of the items)

This way, when you Refresh the dataSource that Gallery1 is filtered from...it will change everything properly and you will not have to rebuild your variables.

Just a suggestion (I used to do lots of the variable thing in the beginning and found it caused more headache than it solved - went to the above example and it was like a rocket)

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Community Support
Community Support

Re: Refreshing SP list passed as context variable

Hi @RomanKorchak,

Based on the issue that you mentioned, I think a global variable (via Set() function) could achieve your needs.

I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the "Navigate" button to following:

Set(SPListVariable, 'YourSPList');
Navigate(ListScreen, ScreenTransition.None)

Set the OnVisible property of the List Screen to following:

Refresh('YourSPList');
Set(SPListVariable, 'YourSPList')

Then use the SPListVariable within your List Screen instead of Context variable.

Note: For your app's performance, when passing the app’s state from one screen to another, create or modify a global variable value by using the Set function instead of by using the Navigate and UpdateContext functions. Please check the following for more details:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/performance-tips#use-global-variables

 

More details about Refresh function, please check the following article:

Refresh function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (12,208)