getodk / collect

ODK Collect is an Android app for filling out forms. It's been used to collect billions of data points in challenging environments around the world. Contribute and make the world a better place! ✨📋✨
https://docs.getodk.org/collect-intro
Other
718 stars 1.37k forks source link

Values in an update form are modified after finalizing the form #6382

Open dbemke opened 2 months ago

dbemke commented 2 months ago

ODK Collect version

the master version 9d5e3aeb7b4f98d321532221572488afc38f0812

Android version

10, 14

Device used

Redmi 9T, Pixel 7a

Problem description

Values in an update form are modified after finalizing the form. When I fill the form I see the correct values (previous properties) but after finalizing the form when I go to "Ready to send” and open the form there are new values in the field where are previous values should be. In the screenshot: on the left - created entity 147147; on the right updated 147147 to 14771477 (check "select tree to update" and circumference vs new circumference) finalizedOfflineUpdateValues

Steps to reproduce the problem

  1. Download a project with registration and update form (e.g. trees registration and trees update).
  2. In Collect set auto send to off.
  3. Fill the registration form and finalize it.
  4. Go to the update form and select the created entity.
  5. Fill updating the entity check if old values are correct.
  6. Finalize the form.
  7. Go to "Ready to send” to the update form and check the old values.
seadowg commented 2 months ago

@dbemke is this only the trees update form? Could you try a different one? We have tests for update forms that aren't having this problem.

dbemke commented 2 months ago

Another form with the same steps reproduced

https://github.com/user-attachments/assets/c0c9e83d-4ce7-43ec-95bb-b721bb28342c

WKobus commented 2 months ago

This issue also occurs for draft forms, finalizing update form changes values of update draft forms

Steps to reproduce

  1. Open and finalize registration form
  2. Open update form, select previously created entity fill form and save it as draft
  3. Open update form again, select same entity, fill form and finalize it
  4. Go to drafts, open update form and check values
lognaturel commented 2 months ago

I think this is confusing but expected. Opening a filled form reruns calculations which means values are pulled from entity lists again. It should work the same way without offline entities — if you update an Entity List or attached CSV and opened a form you had filled previously it will pull in new values. If you don’t want that behavior you can use the once() function or a trigger in form design.

It's always been an uncomfortable thing about edits on the server. Having a chain of updates makes this much more apparent on the client.