Showing existing data on a form to modify from a repeating group

I have a form which the user fills out detailing previous car accidents. Once the user hits save, the form resets ready to accept another entry. There is also a repeating group that shows the entries that the user has made and each of their accidents via a button that says ‘Modify’

What I am trying to achieve is simple, but I want to just confirm the best approach for this. When the user clicks the Modify button, I want the details of that entry to show on the form on the page so the user can revise any errors. Then when they hit Save it simply updates the record.

I wasn’t sure whether states was necessary or perhaps ‘sending data’ to an element could achieve the above.

Hi there, @JS7319… if I was implementing what you described, I would likely use a custom state (which I would set at the page level) combined with putting all of the elements of the form into a group. Then, I would set the Data source of the group to the custom state, and I would set the Initial content/Default value of each of the form’s elements to the relevant field of the custom state’s value.

With the above setup in place, all you have to do when the Modify button is clicked is set the custom state’s value to the current cell’s thing, and the thing’s details will show up in the form. Then, you can put a condition on the form’s submit button to create a new thing when the custom state is empty or to modify an existing thing (the custom state’s value, of course) when the custom state is not empty.

Anyway, that’s likely how I would go about it, and I hope this helps.


1 Like

Thank you @mikeloc this is what I had in mind too.

However, wondering if you could guide me a little on an issue I’m facing with restoring the data back into the form after the user clicks Modify

I can’t seem to configure this solution so that the entire form automatically is populated on the click of the button. Instead what I’m finding is that I can implement a state per field (there about 12 fields on this form), but don’t know how to implement this so I don’t a state for each field.

Where I am getting stuck more specifically is when in the workflow (for the modify button) its asking me to set a value. This value is point to a specific field and not the entirety of the ‘current cell’ to be restored to the form even though the element that is selected is the group and not one specific field.

I hope that makes sense.

Here are some screenshots that might help visualise. The custom state is called Procedure Text

Here is the form’s element field pointing to the Procedure Text in the initial content

And here is the workflow for the Modify button showing that I can only point the state to a specific field and restore one field at a time instead of the entire form from the current cell’s thing (which is what I’d hope to do)

If I am following you correctly here, I assume the state type of your custom state is text? If so, that’s the issue. Make the state type the same as the type of content of the repeating group, and set the state to the current cell’s thing when the modify button is clicked.

Thanks @mikeloc that has worked!

One final question if I may on the last component to this is the ‘Save’ button which makes a change to the existing data after it has been populated in the form.

I decided to make a new button call ‘Amend’ (instead of Save, so it’s clear to the user they are amending existing data and not saving new data). This button appears when ever the state is ‘not empty’ as you have suggested.

What I am finding is that in the debugger, although the app is picking up the value of what’s in the field after I amend it, it’s actually not amending it in the database. I think this relates to some issue with specifying the parent’s thing of the group. In the workflow I have set the instruction to ‘make a change to a thing’ and the ‘thing to change’ is ‘Parent’s group X’. All of the fields are then listed specifying the value of the field to change, as per below:


However, in the debugger, it’s empty - and I presume this is the reason why once the field is populated, the data isn’t being sent back to the app to update.

Do you have any thoughts on what might be causing this? Have I incorrectly specified the thing to change?

Shouldn’t you be making changes to the thing that is stored in the custom state? So, in other words, the thing to change should be the custom state’s value?

Yes, you’re right, the thing that’s been transferred into the form. I’ve picked out the wrong option in the workflow then (I was confused between the custom state values and what is being held in the database).

How can I modify the workflow to modify the custom state value, and thereby update the existing thing stored in the database?

In your screenshot, can you select the custom state in the Thing to change field (remembering to first select the page/element with which the custom state is associated)? If you can’t select it (I can’t remember right this second if you can select a custom state there), you can probably do a search for the thing that is being stored in the custom state.

1 Like

Many thanks @mikeloc you’ve nudged me the right direction, the amend feature now works.

I was initially on the right track, trying to search for the custom state name in the Thing to Change field but was missing out the element to which I associated with.

1 Like

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