cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RomanKorchak
Level: Powered On

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, {listSmiley FrustratedPList}) 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
Community Support Team
Community Support Team

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.
4 REPLIES 4
RandyHayes
Level 10

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)

Highlighted
RomanKorchak
Level: Powered On

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 

RandyHayes
Level 10

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)

Community Support Team
Community Support Team

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.