web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / reset datasource when ...
Power Apps
Answered

reset datasource when button pressed

(0) ShareShare
ReportReport
Posted on by 43

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.

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

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

  • EvanTheGreek Profile Picture
    43 on at

    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 Profile Picture
    76,297 Super User 2024 Season 1 on at

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

  • EvanTheGreek Profile Picture
    43 on at

    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 Profile Picture
    76,297 Super User 2024 Season 1 on at

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

  • EvanTheGreek Profile Picture
    43 on at

    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.

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @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)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard