cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

EditForm not updating record if unused in session

Hi everyone!
So I faced a bug yesterday, and after some testing I figured that it was a bug in the powerapps environment and not in my code. I would like some workaround suggestions.

I have an app that has multiple editforms and displayforms. The issue I am facing is that if I launch the app, and immediately go to view some record in a displayform e.g., DisplayForm1. Then I want to edit the record so I enter an EditForm1, in edit mode. The editform shows right values for the record I want to edit. Now when I change some value in it, and click on the button containing 'SubmitForm', the form does not update the values. It shows it has succeeded and also runs the 'OnSuccess' code of it. But neither does the DisplayForm1 show new values, nor does the backend excel table.

Now on the other hand, if after launching the app I open the EditForm1 in NewForm mode, and add a new record, the form somewhat gets "initialized" which was not happening before. So after submitting a new record in a session, now when I go in the edit mode and edit a record (not even the latest one, just any old record), everything works fine.
I have tried initializing the form in some other ways, by adding 'NewForm' to some button prior to going EditForm for it, but it doesn't work unless at least one new value was submitted in the session. And this is happening with all the forms in the app, so even if I get EditForm1 initialized, I will still be getting the same problem with EditForm2, unless I get it initialized like that separately.
Could this be related to app size? My app has become quite large, is that affecting the behaviour? Although I don't think it is, because the form does pick up right values. It just doesn't update them.

3 REPLIES 3
Highlighted
Community Support
Community Support

Re: EditForm not updating record if unused in session

Hi @Anonymous ,

Based on the issue that you mentioned, I have made a test on my side, and don't have the issue that you mentined.

 

Please consider re-generate a new app based on your data source, then try it again, check if the issue is solved. Also please consider turn off the "Improved app rendering (final validation)" option within Advanced settings of App settings of your app, then re-load your app, check if the issue is solved.

 

In addiiton, please also consider use Patch function to submit your Edit forms data instead of SubmitForm function. Please set the OnSelect property of the "Submit" button to following formula:

If(
    EditForm1.Mode = FormMode.New && EditForm2.Mode = FormMode.New && EditForm3.Mode = FormMode.New && ...,
    Patch('YourDataSource', Defaults('YourDataSource'), EditForm1.Updates, EditForm2.Updates, EditForm3.Updates, ...),  /* <-- Add new record */
    Patch('YourDataSource', BroeswGallery1.Selected, EditForm1.Updates, EditForm2.Updates, EditForm3.Updates, ...)    /* <-- Update existing record */
)

Note: I assume that you use Gallery to list all records from your data source in your app. And I assume that you use multiple Edit forms to submit data into your Excel table data source.

 

More details about Patch function, please check the following article:

Patch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Anonymous
Not applicable

Re: EditForm not updating record if unused in session

Hi @Anonymous are you still experiencing this issue? Was the above reply helpful?

 

@Anonymous 

Highlighted
Anonymous
Not applicable

Re: EditForm not updating record if unused in session

Thank you for your responses. I figured out the solution myself. I will explain it here now. Before the bug, I will tell you a bit more about the application here:
In my application, since I have used a lot of forms, in order to avoid using as many submit buttons I am using variables of type Form. as an abbreviation for "Selected Location", I have named the variable SelLoc.
So I have a dropdown. and the OnChange property of dropdown is something like this:&nbsp;
Set(SelLoc,Switch(DropDown1.Selected.Locations,
"Case 1" , Form1,
"Case 2" , Form2,
......))
So that the "new" and "submit" buttons have their OnSelect set as&nbsp;
NewForm(SelLoc)
and
SubmitForm(SelLoc)
respectively.
I have also changed the Visible properties of all those forms accordingly.
The bug:&nbsp;
Again, in order to avoid too many galleries, I used one gallery and a variable of type Data Source named SelDat (Short for "Selected Data"). And the gallery's data source is set to SelDat. So there is another screen, with another dropdown in it. with OnChange property as:
Set(SelDat,Switch(DropDown2.Selected.Locations,
"Case 1" , Table1,
"Case 2" , Table2,
......));
Set(SelLoc,Switch(DropDown2.Selected.Locations,
"Case 1" , Form1,
"Case 2" , Form2,
......))
In order to have the "Edit" button work, I needed to set both the SelDat and SelLoc at one point. then I can use the code&nbsp;
Navigate('AddingScreen');
EditForm(SelLoc);
And here is where the problem was. The OnChange property of this dropdown was not being executed completely. Since the default mode of all these forms was FormMode.Edit so they did show whatever record I chose from the gallery. But when I tried to edit them and then click "submit". It would give an error, because the SelLoc was not carrying in it the relevant form so submit won't work.
Why I thought it is being executed in edit mode only after being executed in new mode, is because when I used dropdown1 for selecting a form (e.g form1)) and adding new record, the SelLoc was set to the form1. And then when I edit a record in form1, the submit would work, because at that point it had got the right form in SelLoc, and the incomplete execution from dropdown2 didn't matter at this point.
&nbsp;
The solution:

I changed the code of "Edit Record" button to this:&nbsp;
Set(SelLoc,Switch(DropDown2.Selected.Locations,
"Case 1" , Form1,
"Case 2" , Form2,
......));
Navigate('AddingScreen');
EditForm(SelLoc);
I still have no idea why the OnChange was not executing completely.
And although my problem is solved, I would still also like to ask&nbsp;&nbsp; why do you prefer patch function over submitform?
&nbsp;
Thank you.

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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