I have a PowerApp where the underlying data is in a SharePoint List.
I have a button in my PowerApp - which runs a Power Automate flow.
The last part of the flow does an 'Update Item' using the Sharepoint connector.
This works and 10 seconds later a blank field is populated with the required data on an already existing row.
I have a Label in my flow which is connected to that field.
Seems easy...but I cannot see how to display that newly created value into that field....
My PowerApp has 2 screens (my label is on screen 2) and if I navigate back to Screen 1 and then back to Screen 2 - the label with the data correctly shows.
But I don't want the user to have to do that.
Either I would like to have a Timer (where onTimerEnd ... say after 20 seconds .. when the data will definitely be there from the PowerAutomate it refreshes)...or I can have a 'reload' icon which the user can manually click.
I just want that new data to show in a field without having the user navigate back to screen 1 and then to screen 2.
The field is inside a Gallery which is connected to a Sharepoint List as mentioned...however, weirdly if I select the Gallery (Gallery 2) and on the Properties on the right of the screen - it shows:
Data Source: Custom.
(Is this because I have a Gallery on screen 1 pointing to the same SP list?)
I have tried: Refresh (Name of SP List) - but this doesn't update the record either.
Also using Monitor - it looks like it is only refreshing Gallery 1 .. which is on screen 1 and also points to the same Sharepoint List).
How do I refresh this 'Custom' datasource...so Gallery 2 is updated.
Or - is there a better way to achieve this? I am seeing posts about using UpdateContext...but I am not sure I am using it correctly.
The fact that I can navigate out of the screen and back must mean I can do something staying on the same screen and refreshing that label?
Thanks for any advice.
Solved! Go to Solution.
Yes, the reason you see what you see is because you are using a snapshot variable. It never updates until you update it in your app. Thus the, go back to screen 1 and then back to the record.
So, looking at the Items property, this is a simple formula (meaning that some other complexities will not arise), so you really don't need the variable at all.
Now, I'm a little confused why you would have a Gallery that only ever shows one record. Your Gallery1 is the record. Gallery2 does what??
Change the Items property of Gallery2 to : Table(Gallery1.Selected)
Change the OnSelect property of Gallery1 to : Navigate(Detailed, Fade)
I specifically mention the OnSelect formula above to eliminate the selectedItem variable. We will know immediately (by any other errors that pop up) if you are relying on that some place else...which we should then change.
The trick would be to make sure your flow completes. You can achieve this by setting the result of the flow to a context variable:
This will cause the app to wait for the flow to complete.
Then, after that, perform a Refresh on the datasource that is impacted by the flow.
As long as you have no other snapshot variables or collections at play, your label will update properly.
If not, then what is the Text property of the label?
I hope this is helpful for you.
Not entirely sure what you mean by "a Data source that shows as custom". Can you explain that a little?
The key point in the response was to set a throw away variable to the result of the flow. This will ensure that the flow is complete. After that, a refresh on the Datasource will get a fresh set of values in your session table based on the changes that the flow made.
Take your time and just respond back when you get some PC time.
The Gallery shows its Datasource as 'Custom' :
Therefore - when I issue the Refresh (data_source) ... I am not sure what to put into data_source?
The items within Gallery2 are from a Sharepoint List and that datasource is added into the PowerApp.
On screen 1 - I have a Gallery1 which points to the same data_source and that one in the similar screenshot above correctly shows the data_source name.
So - when I do issue the Refresh (data_source) command - it only refreshes that screen....but nothing in screen 2 and I am presuming this is because it shows as Custom?
Though - like I say - I can navigate back to screen 1 and then forward to screen 2 and the field then populates correctly...
Then the question is, what is the Items property of Gallery2? That will reveal the datasource.
The Items property shows as this:
Therefore I tried:
Nothing happened unfortunately - it did not refresh the field.
There is a red squiggle line under the Refresh command which says:
"Only managed connections can be refreshed"
What is selectedItem? That is certainly not a datasource. Looks like some kind of Variable. Which is where your problem is going to be. If you Gallery is based on a variable, then it will never change until the variable is changed. There should be no variable used.
Where is selectedItem defined?
Thanks @RandyHayes - I also have no idea :).
I must have it somewhere....let me try and find it.....I don't suppose there is some kind of 'Find' is there?
I think the mistake was that I used a template app - but I had pretty much wiped out all the components and started again. Perhaps I left some remnants in there.
Though these are brand new Galleries - which I thought were pointing to my new SharePoint lists.
You are certainly pointing me in the right direction and for that I thank you.
If it is a variable (suspected) then you can go to the variable viewer. This is from the menu at the top, choose View then Variables
Yeah, that is definitely not your list. So hunt it down and see where you are setting it and why in the world you would need it.
Check out the News & Announcements to learn more.
Did you know that you can visit the Power Query Forum in Power BI and now Power Apps
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.
Check out our new Discover Your Career Path blog post series and get all the details.