cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
VictorSotnikov
Helper II
Helper II

Should I call Refresh(myDataSource) after SubmitForm(MyEditForm) to update Gallery control?

I have a Canvas app with a Gallery. One of the Gallery fields MyColumn is bound to a [MyTable].MyColumn column in an SQL database.

I also have a form EditForm to edit fields of a selected row in the Gallery. I have opened the EditForm; changed value of MyColumn in the form; and clicked Save&Close button . The button executes SubmitForm(EditForm) code.

The EditForm has disappeared and I was back to the Gallery. I have checked it out that the [MyTable].MyColumn column in the SQL database has been properly updated; but its cell was NOT updated in the Gallery and still displayed old (before I called the form) value.

What should I do to have the Gallery update and display the changes I have done in EditForm? Should I call not just “SubmitForm(EditForm)” but “SubmitForm(EditForm);  Refresh('MyDataSource');” ?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@VictorSotnikov 

If you use refesh, put it in the OnSuccess property of the form. Never chain commands after SubmitForm(). They don't always execute sequentially and you don't want to have them execute if the form isn't successfully submitted.

View solution in original post

7 REPLIES 7
Drrickryp
Super User
Super User

@VictorSotnikov 

If you use refesh, put it in the OnSuccess property of the form. Never chain commands after SubmitForm(). They don't always execute sequentially and you don't want to have them execute if the form isn't successfully submitted.

VictorSotnikov
Helper II
Helper II

"...If you use refesh, put it in the OnSuccess property of the form. Never chain commands after SubmitForm(). They don't always execute sequentially and you don't want to have them execute if the form isn't successfully submitted...." - thank you for the answer.

As I understand, there is no way to somehow "make a dependency link" between the gallery and the EditForm, like "the Gallery should monitor the EditForm and automatically update its context when the EditForm is has successfully closed" - correct? This is my responsibility to put the corresponding code into the  OnSuccess property of the Form.

Drrickryp
Super User
Super User

@VictorSotnikov 

I can't explain it myself but there is a dependency link between the gallery and its SQL datasource.  In general PowerApps works like Excel and a change in a cell automatically changes another cell that uses it in a calculation.  At least it's supposed to work that way.  Does the Items property of your gallery use a table shaping function like AddColumns, ShowColumns, etc.?  Could you test that by putting a data table control on a screen and simply using the SQL table as its Items property?  It should update automatically when the form is successfully submitted without the need for a Refresh(). 

“… Does the Items property of your gallery use a table shaping function like AddColumns, ShowColumns, etc.? …” = no it does not. The Items looks like this:

 

Filter(' MyTable', tinput_SomeOtherField.Text in SomeOtherField)

 

Where tinput_SomeOtherField is a Text Input component for filtering; SomeOtherField is some other column of my SQL table.

What is weird – a couple of days ago I wrote a similar Canvas app (Gallery + Form) that did NOT require any Refresh! After SubmitForm(TheForm) the Gallery was properly refreshed/updated. I see no differences in the two apps; they are quite similar – and however the 2nd one requires to issue the Refresh().

Any ideas – what could be “wrong” in the 2nd App in comparison to the 1st one?

Drrickryp
Super User
Super User

@VictorSotnikov 

Just to troubleshoot the problem, use 'MyTable' without the filter and see if you still need a Refresh for the gallery to show the new item. 

"...Just to troubleshoot the problem, use 'MyTable' without the filter and see if you still need a Refresh for the gallery to show..."

I have tried - no, without the Refresh() the Gallery was not updated.

Drrickryp
Super User
Super User

@VictorSotnikov 

I don't have an explanation for it!  Perhaps someone else can help us. 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,850)