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 variable from ...
Power Apps
Unanswered

Refresh variable from selected item (Collection)

(0) ShareShare
ReportReport
Posted on by 2,567

Hi

 

How do you update a variable from a collection on a selected item from a gallery?

Currently im using the following.

 

Refresh(Datasource);
ClearCollect(MyCollection, Filter(Datasource, Lower(Requester.Email) = Lower(User().Email)));

 

Is it possible to refrehsh the screen for the select item displaying so if the item is update when i already have selected ut i want to fresh it and show the latest added text.

 

Column in sharepoint named "Column1"

Screen in powerapps displaying the text in "Column1"

 

How can i refresh that specific item showing on the screen? Or is my code above enough to do this?

Categories:
I have the same question (0)
  • JimmyW Profile Picture
    2,567 on at

    To clarify.

     

    When i push a button to save my input i want the variable to fetch and update the input so the new input is displayed instantly when i press save button.

  • v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @JimmyWork ,

     

    Is it a standalone app or custom form in SharePoint? 

     

    Refresh(Datasource) will update all the items to the latest, so I think your formula already did what you need.

     

    Regards,

    Mona

  • JimmyW Profile Picture
    2,567 on at

    @v-monli-msft Thank you for answering

     

    It's not working on my save button, but it is working on my refresh button.

    When i click save i want it to display the new text right away, but for some reason it does not work.

     

    My save button On select = 

    If(
    !IsBlank(RichTextEditorComment.HtmlText),
    Patch(
    Datasource,
    Gallery1.Selected,
    {
    'Case Comments': "<b>" &
    Char(13) & Char(13) & User().FullName & "</b>" & "<br> <span style='font-size:12pt'>"& Now()&"</span> " &
    Char(13) & RichTextEditorComment.HtmlText & Gallery1.Selected.'Case Comments'
    }
    )
    );
    Reset(RichTextEditorComment);
    Refresh(Datasource);
    ClearCollect(RecordsTickets, Filter(Datasource, Lower(Requester.Email) = Lower(User().Email)));
    Set(varSelectedTicket, Gallery1.Selected);

     

    My refresh button =
    Refresh(Helpdesk);
    ClearCollect(RecordsTickets, Filter(Datasource, Lower(Requester.Email) = Lower(User().Email)));
    Set(varSelectedTicket, Gallery1.Selected);

     

    Now the refresh button works for some reason but the save will not display the latest added comment until i press refresh.

     

    My box displaying what i enter/save is a htmltextbox = varSelectedTicket.'Case Comments'

  • JimmyW Profile Picture
    2,567 on at

    For some reason it only updates on the second refresh.

     

    So now i have to the following.

     

    Refresh(Datasource);
    ClearCollect(RecordsTickets, Filter(Helpdesk, Lower(Requester.Email) = Lower(User().Email)));
    Set(varSelectedTicket, Gallery1.Selected);
    Refresh(Datasource);
    Set(varSelectedTicket, Gallery1.Selected);

     

    But if i have Galler1.Selected.'Case Comments' in the HtmlText box instead of (varSelectedTicket.'Case Comments') i dont need to refresh 2 times but i get a peformance warning because im not using a variable from my first screen. But refreshing from a collection seems to need 2 refresh?

     

  • Sajarac Profile Picture
    3,295 on at

    Hi @JimmyWork , quick question? 

    Did you find a solution for your issue? I am having some similar problem when I select the gallery the variable is not updating and keeps previous value.

     

    I will appreciate any response.

     

    Regards

  • JimmyW Profile Picture
    2,567 on at

    @sajarac If i recall correctly i set it to LookUp instead that solved it directly so i set my variablie to LookUp and then reset that each time i do something.

  • Sajarac Profile Picture
    3,295 on at

    Hi @JimmyWork , thanks for your response, silly question how do you reset that variable?

  • JimmyW Profile Picture
    2,567 on at

    @sajarac Sorry for my bad wording I actually set the variable again.
    For example when i change the status on my item to close and i want the status to be instant visible i do the following.

    I use the variable on the Gallery when i select it.
    Set(varSelectedStatus, LookUp(SharePointList, ID = Gallery.Selected.ID).Status.Value);
    I then use the same when i press save. Then i Save the changes and set the variable again as above.

    The item status i then refer to the varSelectedStatus, this way it's instant updated.

  • Sajarac Profile Picture
    3,295 on at

    Hey @JimmyWork ,

    I did a slight change last night in the OnSelect property of the gallery. Instead of Gallery1.selected I put this:

    Set(varCustomerName,ThisItem.Title);

     

    Gallery1.selected replaced by ThisItem.

     

    By doing this now the variable gets updated. So I am ok now. Only one minor problem if I come back to the page where the gallery is is seems like the item is selected but if fact is not I have to click again to select. Other than that is working as expected.

     

    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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 181 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 112 Super User 2026 Season 2

Last 30 days Overall leaderboard