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 / Refreshing form based ...
Power Apps
Suggested Answer

Refreshing form based on variable after submit

(0) ShareShare
ReportReport
Posted on by 46
Hi guys,

I have a form that pulls from a variable that is populated from my SharePoint data source when selected from a gallery (OnSelect = Set(globalCurrentRecord,ThisItem)).

Whilst the data source updates automatically when the form is submitted, the variable then needs updating using Set(globalCurrentRecord, TicketsGal.Selected).

My problem is, when I chain this function on the back of the button I am using to save the form, it doesn't appear to update.  If I add this function to a button on it's own however, it works correctly and updates.
 
 
 
Example:

 
 
 
 
Data source and gallery values updating correctly:
 
 
Variable not updating after Set is trigged after the SubmitForm:

 
Categories:
I have the same question (0)
  • Suggested answer
    YordiVN Profile Picture
    12 on at
     
    the gallery is probably not refreshed yet when the Set function has been called.
    Here are a couple of possible sollutions to your problem:
    • In the set do a lookup on your datasource to get the latest update:
      Set(GlovalCurrentRecord, LookUp(DataSource, Id = TicketsGal.Selected.Id));
    • Refresh the datasource before the set:
      Refresh(DataSource);
      Set(GlobalCurrentRecord, TicketsGal.Selected);
    • Reset you gallery and adjust the default selected item:
      • Reset Gallery before set
        Reset(TicketsGal);
        Set(GlobalCurrentRecord, TicketsGal.Selected);
      • Gallery default item
        If(IsBlank(GlobalCurrentRecord), Blank(), LookUp(DataSource, Id = GlobalCurrentRecord.Id))
         
  • enriqueglopez Profile Picture
    516 Moderator on at
    You have to refresh the item after is updated in SharePoint. Substitute your Set(globalCurrentRecord, TicketsGal.Selected) with this: 
     
    Set(globalCurrentRecord, LookUp(YourList, ID = globalCurrentRecord.ID))
     
    This will search the item using the ID and refresh the properties of your variable at the end.
  • dbarnesab Profile Picture
    46 on at
    Thanks you for the quick response.  I've just tried this method with unfortunately no success.  I agree it is clearly something to do with timings.  It is as if the Set function is being ran before the data is updated.
     
     
    I have also tested forcing in a Refresh of the data set first (although this will be done on save anyway) with no change.
     
    Kind regards,
    Dan
  • enriqueglopez Profile Picture
    516 Moderator on at
    dbarnesab try to add that Set() in the OnSuccess property of the Form that you are submitting.
     
    That will guarantee that the code is executed after the form is (successfully) submitted. 
  • timl Profile Picture
    36,774 Super User 2026 Season 1 on at
    Hi  dbarnesab
     
    The method that enriqueglopez describes (calling Set in the OnSuccess of the form) is the correct approach. 
     
    To add to this, you would reference the LastSubmit property of the form to return the record that was just added. 
     
    The OnSuccess formula would look like this: 
     
    Set(globalCurrentRecord, Self.LastSubmit)
     
  • CU08010028-0 Profile Picture
    2 on at
    Timl, thanks so much for that last one!
  • WarrenBelz Profile Picture
    154,787 Most Valuable Professional on at
    There is a much simpler and more reliable method of ensuring the data in your Form refreshes - set the Item of the Form to directly look up the data source
    LookUp(
       'Pre-Sales Booking In', 
       ID = globalCurrentRecord.ID
    )
    Any action on the Form will automatically re-query the data source. It is also a good idea (as @timl has suggested) to reset the Variable OnSuccess of the Form to pick up any field changes (although the ID will not change, so the form will still refresh).
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 493 Most Valuable Professional

#2
11manish Profile Picture

11manish 479

#3
Haque Profile Picture

Haque 328

Last 30 days Overall leaderboard