Best way to reset an edit form back to original values?

So say I have a form (group edit contact form) to edit an object stored on my database, let’s call it contact. It has a name, a birthdate, and a checkbox for employed, each in their own groups within the group edit contact form.

The inputs are all disabled and linked to a custom state on the group edit contact form called Edit that by default is set to no.

There is an Edit button at the bottom of the form that when clicked triggers a workflow to change the custom state to yes, which enables all the inputs through a conditional statement on each, hides the edit button, and shows 2 new buttons, Cancel and Save.

When Save is clicked, a workflow changes the custom state Edit back to no, and updates the object with the new input values.

When Cancel is clicked, a workflow changes the Custom state Edit back to no, and should reset the inputs back to the original state (what was stored in the database for that object). This is what I’m having trouble with, as I’m having difficulty resetting the values.

For example: David, 1/1/1991, unchecked box. I go to edit the form, and change the date to 2/2/1992 and check the box. Then I have second thoughts and click cancel. Now the values stay on the screen, even though they are not saved in the database for that object.

This feels like it should be an easy thing to do, and I’m probably missing something obvious here, but I haven’t figured this out a clean way to solve this.

I realize that the reset inputs or reset group don’t work here as there were no fields processed through the workflow (since I didn’t save anything), so as a workaround I added a Make changes to a thing in the Cancel workflow using all the fields, but added a conditional that will never evaluate to true (this url is, and then added the reset inputs afterwards. This worked, but it feels wrong, lol.

What would be a better way to solve this problem?

You can group input elements in a parent group and use “reset data” action. Just tested with a date/time picker element and it works.

1 Like

That was the first thing I tried and it didn’t work, or so I thought.

I have a caveat that I didn’t mention, which is that for the date, I have a conditional when the edit state is yes, the minimum date has to be tomorrow (current date/time + 1 day). So if the date was in the past, (before the minimum) it gets automatically updated to the minimum. I have noted that reset inputs or reset group does not revert that date back.

I was only working on the date so I didn’t test the other fields, but yes the reset group was working so thank you for bringing that up.

So the issue is that by changing the minimum date on the conditional, it doesn’t get the reset group or inputs to recognize its been changed. I need to figure out how to get that date to go back.

So here Is a quick setup that worked in my test app:

  1. I have a checkbox that changes custom state “edit” (boolean) to “yes” or “no”
  2. Date/time picker wrapped in a group [to have an access to “reset data” action]
  3. Default initial content = XX/YY/ZZZZ. Conditional initial content = XX/YY/ZZZZ + (days): 1 (when custom state “edit” is yes)

In the WF where custom state is set to “no” I have following action “reset data” for the group where date/time picker element is located.

1 Like

Are you editing the date then clicking cancel?

If so it will work. But if you just click edit (which would cause the date to move up by 1 day), then click cancel without changing the date, it won’t reset. At least for me it doesn’t.

I’m using current date/time + 1 day as my conditional initial content, whereas the actual content is in the past, so it automatically gets updated to tomorrow when clicking the edit button. If I don’t touch that date field and just click cancel, that’s when it won’t reset. If I actually click on the date field and edit it, then cancel will indeed reset it.


1 Like

Ok, I just reread your post above and I understand now. You are changing both the initial value and the minimum date on the conditional to be the current date/time + 1 day. I did that and got it working now.

Thank you for helping me through that. :grinning:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.