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 / 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
    503 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
    503 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,393 Super User 2025 Season 2 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)
     

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