cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nav12
Helper I
Helper I

Showing newly updated field in Sharepoint list inside PowerApp

Hi,

 

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@Nav12 

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.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

18 REPLIES 18
RandyHayes
Super User III
Super User III

@Nav12 

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:

   UpdateContext({flowResults: yourFlow.Run(params)})

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
Nav12
Helper I
Helper I

Thanks Randy. The flow definitely completes as I can see the data in the SP list. I’ve tried refresh - but I’m not sure it is updating the data source based on what monitor is showing. How do I refresh a Data source that shows as custom? I’m not going to be in front of my PC for another day; but I’ll let you know what is behind that field then. Thanks for replying.
RandyHayes
Super User III
Super User III

@Nav12 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
Nav12
Helper I
Helper I

Hi Randy,

 

The Gallery shows its Datasource as 'Custom' :

 

Nav12_0-1619089557214.png

 

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

RandyHayes
Super User III
Super User III

@Nav12 

Then the question is, what is the Items property of Gallery2?  That will reveal the datasource.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
Nav12
Helper I
Helper I

Hi @RandyHayes 

 

The Items property shows as this:

 

selectedItem

 

Therefore I tried:

 

Refresh(selectedItem)

 

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"

 

Thanks!

RandyHayes
Super User III
Super User III

@Nav12 

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?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
Nav12
Helper I
Helper I

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.

RandyHayes
Super User III
Super User III

@Nav12 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (37,142)