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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Refresh() not working ...
Power Apps
Answered

Refresh() not working properly

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi everyone,

 

I facing an issue with global variables and the refresh() function. I hope someone can help.

The overall idea is that I only want to change my list name once in a global variable and it gets used everywhere in the app.

 

 

In my onStart I initialize a global variable to be set to the SharePoint List connection of my app and refresh it.

Set(SPList, 'Test List');

Refresh(SPList)

 

Now I would assume that everytime I use the "SPList" variable it uses the cached SPList data in the app.

It works fine for formulas and conditions. 

But as soon as I do a Refresh(SPList) anywhere in the app, in a button or an onVisible, the function simply does nothing.

It won't get the new information of the SharePoint. If I reload the whole app it works. 😐

Anyone maybe got an idea what I'm doing wrong or why it's not working like that?

 

Greetings

Categories:
  • DownForce Profile Picture
    152 on at

    Refresh() is used to refresh a datasource. A variable is not a datasource. Just use the Set() command to define the variable again.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yeah I know, but the Variable is set to the datasource, but it seems that the function won't recognize it as one.

  • DownForce Profile Picture
    152 on at

    My advice would be to use a collection instead of a variable since collections are better used with tabular data. In your App.OnStart

    ClearCollect(colSPList, 'Test List')

     

    Then on your button/icon/Screen.OnVisible do the same thing.  But, keep in mind, collection or variable are subject to delegation which means if your datasource has more records than the delegation limit in your app, you won't retrieve all of the records.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I also tried that,

    but the main reason I want to use a variable is, so I would only have to change it at one command to be set to 'Test List' and not at every single ClearCollect or Refresh.

    Because on different screens I want the connection to be refreshed with the onVisible or onSelect of a button

    and that seems no to work with a global variable being set to the datasource.

  • DownForce Profile Picture
    152 on at

    I don't understand what you are saying. You only have to ClearCollect when you want that function to run. So only put it on the OnVisible or OnSelect when you want it to execute.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yeah, you still don't understand my problem.

     

    I want to set the datasource once for the app in a variable.

    Then use that Variable as reference for the datasource everywhere else in the app, instead of the actual datasource name.

    When I do that, the Refresh() wont work with the variable, even though the variable is set to the datasource.

  • DownForce Profile Picture
    152 on at

    So...the datasource is already set in the app...that happened when you added it to the app. There is no need to set it to a variable every time the app is run.

     

    If you insist on working with the variable or a collection, Refresh isn't going to work for you...you need to set the variable or ClearCollect again so that it will then go and get any new or updated records.  

  • WarrenBelz Profile Picture
    156,774 Most Valuable Professional on at

    @Anonymous ,

    To save any more discussion here, you simply cannot refer to a data source using a Variable - also if you are trying to use difference data sources on the same Form or Gallery, you are going to face significant difficulties even if you manage to get it to accept valid code for this.

  • Verified answer
    Cat Schneider Profile Picture
    488 Most Valuable Professional on at

    From all that I just read, it looks like you are trying to use the variable name as a stand-in for the datasource, as if the variable and datasource are interchangeable; meaning to you a refresh on the variable would be the same as a refresh on the datasource. Unfortunately that is not how these types of variables work in Power Apps. I believe what you are trying to do can be accomplished using environmental variables, but I'm not positive on how to set them up. I think I've only done it once, maybe 2 years ago, and I think it requires you to export your app as part of a (managed, maybe?) solution, then import it, and set the environmental variables values on import. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi there,

    you got it! Thanks for the input. I know my way around environment variables as well. But I wanted to do within the app.

    And I thought a data connection also would be counted as an object reference as mentioned in the MS docs:

    Set function in Power Apps - Power Platform | Microsoft Learn

     

    But I guess it's not possible then. Thanks!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 337 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard