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

reset datasource when button pressed

Hello,

I have an app tied to SharePoint site. All is working yet I am having an issue with the data reflecting in real time to the app when an update is made. Here's the run down.

  1. User selects purchase item
  2. user approves item with a button and enters comment, comment is entered into SharePoint list and approval status based off of button pressed.

All is working yet when the approval or rejection is made the status does not show in the app till I refresh the data. So I am thinking I was going to add formula to reset data source once button is pressed unless I can find a way to have the app refresh every second as multiple users will use this to make approvals at the same time, also do not want someone to make a change and not see it was made. I will also be disabling the button once the cell shows a status is updated.

 

Any assistance will help. Thank you for your time.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@EvanTheGreek 

Yes, that was only part of it!  You needed to also do a Refresh on the datasource after that formula.

So...

UpdateContext({flowRes:Approved.Run(Accrualinfo.Selected.ID,Commentbox)});

Refresh(yourDataSourceName)
_____________________________________________________________________________________
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

7 REPLIES 7
RandyHayes
Super User III
Super User III

@EvanTheGreek 

Assuming then that you are referring to changes made outside of your app (i.e. user approves/rejects from another app or means).  If so, then your best bet would be to provide a refresh on the datasource in timed refreshes.  Doing so every minute might be overtaxing on your app, as refreshes are "expensive" on performance. 

To do this on a timed basis, add a timer control to your app and set the duration to 60000 which will be every minute.  Then in the OnTimerEnd action, place the following formula:  Refresh(yourDataSourceName)

 

If you find that this becomes a burden on your app to constantly refresh, then you might also consider doing a revert on individual records.

 

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

Hello Randy,

 

Thank you for responding. Is there a way I can have the data refresh when they press the approve or reject button? No changes will be made outside of the app as they are going to depend on the app to be the only source of approval.

RandyHayes
Super User III
Super User III

@EvanTheGreek 

Then I'm a little confused....when you update a datasource within your app, the datasource will immediately reflect the change you just made.  There is no need to refresh the datasource.

The only time you need to consider refreshing the datasource is when some other method is used to change the datasource outside of your app - like a flow, another user in another or the same app, someone directly interacting with the data list, etc.

_____________________________________________________________________________________
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

Actually there is a flow tied to it. The buttons are tied to a flow, the flow sends change to list and adds comment, then it emails a response to the supervisor and the accruer with the status. I have a gallery on the left that displays the tickets which once selected shows the detailed information on the right side as this is a web based app. Was trying to have a fluid app that does not have to change screens between. I am also trying to figure out how to clear out the comment box once button is pressed and a couple other features, but that a different story. I had to refresh to get this data to display after I hit the button.

EvanTheGreek_0-1623434886438.png

 

RandyHayes
Super User III
Super User III

@EvanTheGreek 

Yes, so the flow is external and will update the list outside of the app.

In this case, I would set a formula to execute your flow run and store the result in a variable.

ex.

   UpdateContext({flowRes: yourFlowName.Run(params)})

 

This will cause your app to wait for the complete execution of the flow run.

Then immediately after that, either do a full Refresh on the datasource, or Revert the record to only update that one in your 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

It did not work. Here is the formula I entered.

 

UpdateContext({flowRes:Approved.Run(Accrualinfo.Selected.ID,Commentbox)})

 

It still runs but does not refresh data source.

RandyHayes
Super User III
Super User III

@EvanTheGreek 

Yes, that was only part of it!  You needed to also do a Refresh on the datasource after that formula.

So...

UpdateContext({flowRes:Approved.Run(Accrualinfo.Selected.ID,Commentbox)});

Refresh(yourDataSourceName)
_____________________________________________________________________________________
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

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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,629)