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

Show what fields have changed in a form. Unsaved state persists after OnSuccess()

I have a somewhat convoluted form with some defaults being set when the form appears, i thought this was the reason for the persistent unsaved property for the form, but it seems to be something else. I'd like to create an option that automatically saves eventually, but only want to give the user an indication that the document is saved to begin with. This is currently done with making an icon visible when the form Unsaved is false. 

 

Could it be that OnSuccess does not reset the Unsaved property?. I was thinking it was highly probable that one of my fields have some issue because of some custom default-values being set based on values in other fields etc, but I have tried disabling and removing all custom fields without success.

 

I'd like to understand what field or mechanic that is causing the persisting unsaved-state, this also got me thinking that it could be useful to make some indication on the fields that are changed and unsaved. I can always make use of the OnChange function, but I imagine there is a better solution. Perhaps there is another way to solve this, however i cannot find the values that trigger the unsaved state to determine the best way to proceed.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @hjaf,

 

Could you please share a bit more about your scenario?

Do you mean that the form data could not be saved into your data source when your submit the form (Using SubmitForm function)?

 

I don't agree with @Drrickryp's thought. I have made a test on my side, when the Edit form control is in New mode, the EditForm1.Unsaved formula would always return false, regardless of whether or not there is a default for any field. The GIF Screenshot as below:Test1.gif

 

 

The UnSaved property (of Edit form control) would return true only when the Edit form control contains user changes that have not been saved.

 

More details about the UnSaved property of the Edit form control, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-form-detail#key-proper...

 

In addition, the OnSuccess property of the Edit form control would not reset the UnSaved property automatically in default (except that you add formula to force resetting the Edit form, then the UnSaved property would be reset).

 

I also made a test on my side, after I submit the form, the UnSaved property still return true. It means that the UnSaved property of the Edit form is not reset after you submitted the form (Just as you thought).

 

As an alternative solution, if you want to the OnSaved property to be reset after you submit your form, please take a try with the following workaround:

 

Set the OnSelect property of the "Submit" button to following formula:

 

SubmitForm(EditForm1);
ResetForm(EditForm1) /* <-- Add this code to force resetting the Edit form */

 

Or

 

Add the following formula within the OnSuccess property of the Edit form:

ResetForm(EditForm1)

 

Note: The Editform1 represents the Edit form control within your app.

 

Best regards,

Kris

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.

View solution in original post

6 REPLIES 6
Drrickryp
Super User II
Super User II

Hi @hjaf,

I was trying to reproduce your situation and could not do it as long as the form is in Edit mode. However, when the form mode is new, it automatically assumes that it is unsaved, regardless of whether or not there is a default for any field.  I tested this by setting the Visibiility property of the Save button to Form1.Unsaved and it was always visible when the Form mode was new.  If was never visible when the Form mode was Edit until one of the fields was changed.  

That is really strange, i have confirmed that the editmode is Edit using a label for that as well. Only if i change the lookup field to view in the editor the unsaved property becomes false. This is a somewhat convoluted form, could be that i have some fields with defaults referring to the lookup field. But its still somewhat strange that it depends on the lookup-field being in editable or not. 

v-xida-msft
Community Support
Community Support

Hi @hjaf,

 

Could you please share a bit more about your scenario?

Do you mean that the form data could not be saved into your data source when your submit the form (Using SubmitForm function)?

 

I don't agree with @Drrickryp's thought. I have made a test on my side, when the Edit form control is in New mode, the EditForm1.Unsaved formula would always return false, regardless of whether or not there is a default for any field. The GIF Screenshot as below:Test1.gif

 

 

The UnSaved property (of Edit form control) would return true only when the Edit form control contains user changes that have not been saved.

 

More details about the UnSaved property of the Edit form control, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-form-detail#key-proper...

 

In addition, the OnSuccess property of the Edit form control would not reset the UnSaved property automatically in default (except that you add formula to force resetting the Edit form, then the UnSaved property would be reset).

 

I also made a test on my side, after I submit the form, the UnSaved property still return true. It means that the UnSaved property of the Edit form is not reset after you submitted the form (Just as you thought).

 

As an alternative solution, if you want to the OnSaved property to be reset after you submit your form, please take a try with the following workaround:

 

Set the OnSelect property of the "Submit" button to following formula:

 

SubmitForm(EditForm1);
ResetForm(EditForm1) /* <-- Add this code to force resetting the Edit form */

 

Or

 

Add the following formula within the OnSuccess property of the Edit form:

ResetForm(EditForm1)

 

Note: The Editform1 represents the Edit form control within your app.

 

Best regards,

Kris

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.

View solution in original post

The Form.Unsaved property is notoriously unreliable.

In my experience, it only evaluates correctly about 20% of the time.

 

It's quite a major bug that myself and many others have reported on this forum and to Microsoft many many times, and in the past nearly 2 years, we've still not had any response from Microsoft of when the Bug is going to be fixed - In fact, we've not even had an acknowledgement of the issue.

 

My advice is to ignore this property and write your own validation formula.

 

James.

seadude
Memorable Member
Memorable Member

So... whats the deal with Form.Updates? It doesn't work for me (always returns true in BOTH View and Edit forms when nothing has changed). 

 

Looks like there has been a lot of questions on how to properly use it:

This post if from 2018(!)

Another blog about it in 2018...

https://thorprojects.com/blog/archive/2018/05/24/powerapps-forms-bad-and-too-many-updates/ 

 

Is this being addressed by Microsoft? Its a built-in way to check if anything has changed in a form... pretty darn handy right?

seadude
Memorable Member
Memorable Member

Interesting... so, this is weird. I know how to determine if a field in a form has changed by setting a variable OnChange of each field (kind of a pain). 

It sure seems like form.Updates should be doing the check. I thought I'd try the old "Pen input change" trick, but that didnt' work either. 

 

**Example:**

- OnVisible of screen with form: 

Set(varOriginalForm, Form.Updates)

seadude_1-1613882431689.png

 

- DisplayMode of Submit button:

If(varOriginalForm = Form.Updates, DisplayMode.Disabled, DisplayMode.Edit)

 

**Results:** Invalid argument type

seadude_0-1613882401992.png

 

**Also tried:** in/exactin. No go.

 

How are others determining changes in forms? 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

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

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (46,106)