cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gradyd
Regular Visitor

View Form not updating after edit

I have a custom built powerapp that is using sharepoint as the data source. I have a form that after I edit and go back to ViewForm it does not show the updates. Here is the flow.

 

  1. Item selected from Gallery1 with Datasource1
    1. Navigates user to a new page with a  form that displays Gallery1.Selected Info
    2. On this page is there is also a second Gallery, Gallery2
      1. Filter(DataSource2, Field.Id = Gallery1.Selected.Id)
  2. User selects item from Gallery2
    1. Navigates user to a new page that displays a form, editForm, defaulted to View showing DataSource2 with Item of Gallery2.Selected
    2. User clicks button on page with OnSelect set to EditForm(editForm)
    3. User makes changes and clicks Save button on page with OnSelect set to SubmitForm(editForm)
    4. EditForm has an OnSuccess set to 
      1. ViewForm(editForm)

 

The problem is after editForm is submitted it is successful and switches back to the View mode but the updates disappear. I can confirm on the sharepoint list that the updates were successful and if I navigate away from this page and back to the item it then shows the correct values. How can I get it to show the correct values without navigating away and coming back?

 

I have tried a handful of Refresh(Datasources) in different trigger locations, onsuccess/onclick, but nothing I do makes it show up without having to navigate to a different page and reselecting item from Gallery2.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

@Gradyd If I understand it right, the correct record is show after edit, but the changes are not. I think that's because the Form is pointing to the record in the Gallery and although the datasource has been updated, that particular record has not been updated in the Gallery (the record in the Gallery still has the old values).

Please try and do a Refresh(Datasource) and also a Reset(Gallery).

 

View solution in original post

@Gradyd 

You can avoid this by using Lookup(datasource, ID=Gallery.Selected.ID) as the Item property of your forms. 

View solution in original post

8 REPLIES 8
CNT
Super User
Super User

@Gradyd Set the default of Gallery 2 to editForm.LastSubmit

Gradyd
Regular Visitor

Thanks for the idea! I updated the default and, sadly, now when the form is submitted and switches to VIEW it says No item to display which makes me believe that the Gallery2.Selected has lost its context with this update. 

@Gradyd As I understand, both Gallery 2 and the editForm have the same datasource. When a New Record is added to this datasource automatically that record should be added to Gallery 2 (unless you are doing some Filter). editForm.LastSubmit in the default of Gallery 2 will make sure this new record is selected. 

Are you able to see this New Record in Gallery 2? Is it selected?

Because Gallery 2 is in a different Screen it may be a good idea also to add a Reset(Gallery 2) in the OnSuccess.

Gradyd
Regular Visitor

Sorry I did a poor job of explaining what's going on, and I might be going about it the wrong way. 

 

Same data source but Gallery2 does have a filter on it. It is displaying the expected results no problem. What I am creating is a view/edit ability. I pick an item from Gallery2 and it takes me to, call it, page3. Page3 just has a form, editForm, on it and some buttons. The form defaults to view and there is a button that triggers the EditForm(editform) event. I make edits and click a different button to Save. The save button does a SubmitForm(editform) and then there is a ViewForm(editform) attached to the OnSuccess putting it back into view now that the updates are done. 

 

What was happening, before changing default was that it would submit the updates to the record successfully but when it switched back to view it would not show the changes/updates to the record. 

@Gradyd If I understand it right, the correct record is show after edit, but the changes are not. I think that's because the Form is pointing to the record in the Gallery and although the datasource has been updated, that particular record has not been updated in the Gallery (the record in the Gallery still has the old values).

Please try and do a Refresh(Datasource) and also a Reset(Gallery).

 

@Gradyd 

You can avoid this by using Lookup(datasource, ID=Gallery.Selected.ID) as the Item property of your forms. 

This option appears more performant in my application and is what I ultimately am using. Both solutions worked great though!

This should be the accepted answered. 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (2,835)