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

Issues with Form.UnSaved

Not sure if this is a bug or expected behavior, i have a form with a bunch of text boxes, lookups, dates etc all going back to an SQL database.

If i setup the form with dates, dropdowns (with the correct allowed values and defaults) the Form.Unsaved works correctly, make a change to a drop-down, updates = true, change back , updates = false. THe issue comes in with Text boxes. The fields in the database default to ('') and then are are varchar(5000). PowerApps will always report that the form has changes when it loads even if the field is blank. I found that if you add TrimEnds() to the default value of the data card (for example TrimEnds(ThisItem.Issue1) where issue1 is a field) then it works correctly. Anyone else come across something like this or am i missing something in the database setup?

 

Thanks!

25 REPLIES 25

I'm also seeing form.Unsaved as always true.

I need to monitor state of the form in order to control the DisplayMode of the Submit button. 

- If no changes have been made, DisplayMode.Disabled else .Edit

Also need to monitor state of form to control visibility of "Are you sure?" popup

- If changes have been made, show "Are you sure?" popup else navigate directly to previous screen

.Unsaved was my method. Now no longer seems to be working. Need help here. 

 

Thanks

Also issues with Form.Valid?

Scenario:

- I have 4 fields marked as Required (see asterisks)

- The text box is set to: "Is this form valid?: " & Form.Valid

  - As you can see its set to true.

  - It should be false until the required fields are filled in.

- The Default property for these fields is set to:

  - If(frmForm.Mode = FormMode.New, Blank(), Parent.Default)

  - Also tried just setting them to Parent.Default. No change. .Valid still evaluates to true. 

image.png

Whats up here? I use .Valid for a lot of things!

This issue is there for several months now. MSFT does not react on it. I made an app which sometimes shows .Unsaved correctly and sometime not. I think this is a bug. One thing to be aware of is that this property only works on a Edit form (which you can switch in mode of course).

Frequent Visitor

I was having this same problem, but mine is not querying a SQL table. Solution seems to be in the cards, and I believe there are some back end connections that are best left untouched. Flip any cards that you don't want touched to DisplayMode.VIEW and similarly, if you have fields that you want to customize the default properties for display purposes only within a card, I would instead put an additional text box or something - not change the properties of the original control. Simply flip the card's original control to Visible false. With the new control you have added, you can use the ThisItem property to propagate a custom field within a card without messing with the cards default properties. The heart of what I believe was screwing up mine was that I attempted to copy and paste prior constructions and just change the update property of the card to the new field, that seemed to disassociate the appropriate defaults and permanently render the form unsaved=true. Solution is to delete the custom cards and rebuild from scratch. For mine, I had added custom field that I DID want to have updated with form submission, so I added a patch function ahead of the submitform function to update that field. Naturally, that workaround doesn't update the Unsaved property of the form. You could do something like write an addendum to your needed Unsaved formula to check if the exogenous control's current state matches the record's "default" state for that field, but this adds an additional query to the server. For example: Lookup(DatabaseName, ID=IDDataCardValue.value).Exogenous=ExogenousControl.value

Ah I see!  Would I have to do this for every data card or could we do this for the form itself?

That's a really good question - since I'm not using and haven't tried any validation formulas I don't have a good answer. However, my first shot would be to place the validation formula in the submit form button. Mind you, cancel form, you will also want to reset(exogenouscontrol) in addition to resetform(form)

Advocate V
Advocate V

*bump*

I experience the unexpected behavior as well. (again) 
I use a lot of forms in my apps, and I have yet to figure out the reason for this unexpected behavior. I sometimes have to re-create the entire form to resolve it 😕

There are other issues with forms that I have speculated to be related to the Unsaved property. e.g the order and layout of fields when some fields (datacards) are hidden. again, pure speculations.

When issues are not answered in the forum I'd suggest creating a ticket: 
https://powerapps.microsoft.com/en-us/support/pro/


I created a "pure" PowerApp from a SharePoint list as my reference. So I added a label on the EditScreen and it showed "false" for EditForm1.Unsaved - as expected.

I could also move and resize input fields without issue.

But as soon as I replaced the Default value of one input field from Parent.Default to a formula the label text would switch to "true" and just stay there - until I changed the Default value back to Parent.Default.

 

That is annoying!

it is definitely related to the default value and the form setting values when bull. I have found this to be a particular problem when there is a date picker and the source value is Null. There is a not very obvious place where the picker inserts a default value. Once removed i did not get the unsaved issue. this can be achieved by doing the following steps Select DateCardValue -> Advanced Tab -> Remove everything in "InputTextPlaceholder" :slightly_smiling_face: now i need to find the same for a toggle 🙂 Kudos to:- @https://powerusers.microsoft.com/t5/Building-Power-Apps/DatePicker-empty-value/td-p/38305

it is definitely related to the default value and the form setting values when bull. I have found this to be a particular problem when there is a date picker and the source value is Null. There is a not very obvious place where the picker inserts a default value. Once removed i did not get the unsaved issue. this can be achieved by doing the following steps Select DateCardValue -> Advanced Tab -> Remove everything in "InputTextPlaceholder" now i need to find the same for a toggle 🙂 Kudos to:- @https://powerusers.microsoft.com/t5/Building-Power-Apps/DatePicker-empty-value/td-p/38305

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (69,890)