Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

Refreshing form based on variable after submit

(0) ShareShare
ReportReport
Posted on by 35
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:
  • timl Profile Picture
    34,933 Super User 2025 Season 1 on at
    Refreshing form based on variable after submit
    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)
     
  • enriqueglopez Profile Picture
    475 Super User 2025 Season 1 on at
    Refreshing form based on variable after submit
    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. 
  • dbarnesab Profile Picture
    35 on at
    Refreshing form based on variable after submit
    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
    475 Super User 2025 Season 1 on at
    Refreshing form based on variable after submit
    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.
  • Suggested answer
    YordiVN Profile Picture
    12 on at
    Refreshing form based on variable after submit
     
    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))
         

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,537 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,908 Most Valuable Professional

Leaderboard