Displaying saved/selected items from a Repating group

Hi,

I need some help figuring out how to display some data in my app.

I have a “create client” page with a RG showing a number of items which can be selected/ deselected and saved using custom states.

Looks like this in bubble:
Screenshot 2023-08-12 at 16.03.43

Looks like this in the app: (the blue ones are selected state)

The custom state is a list of “treatment_tags".
Screenshot 2023-08-12 at 15.58.51

When I save the New Client this is how It looks like in workflows:
The list I set in custom states are saved to the database-field “treatmentwish” as text (not a list) and ends up like text separated by “,”
Screenshot 2023-08-12 at 15.59.47

Here come’s my problem…

When I later want to view/edit this client and see the the treatments they selected on a separate “edit” page I would like to have the treatments selected (the blue ones) in “create client” already selected when I open the edit page (and the be able to deselect and pick others if needed)

Any ideas?

I’m relatively new to Bubble so I’m sure there are better ways to to this whole thing…. Any help appreciated! :slight_smile:

Thank you! :smiley:

Would be easier to just change your data structure to save the treament tag as a list of treatment tags instead of text as a single field separated by comma.

But…take your single text field separated by comma and create a list from it and save as custom state list ‘selected tags text list’ and when you use that single field to set the state use the fields value and the operator :split by and split by the comma

Then in the repeating group that shows the tags in order to show it as having already been selected add to the conditionals tab the condition when 'current cells treatment_tag (whatever the name of the value is that stores the tag value in the db) is in and the custom state list that you would have created via the single text field.

Then when the select a treatment_tag add that value to the list
…keep in mind all of this needs to be text now, show again, whatever the name is you have on your treatment_tag data type/or option set if that is what it is, to show the name of it is what you send into the custom state list and not the treament_tag itself

Then when you want to save it, just save the custom state list as :each items value into your single text field (this should automatically have the comma separated, but if not you’d be able to use the :split by operator I think)

But again, would just be so much easier to save the treament_tag itself as the list of treatment_tags and not as a single text field separated by comma

Thank you SO much! I’m not sure how I missed this…
I restructured it like you said and saved it as a list using “add list” to create the list and then “set list” on the edit client page to update/change the list of treatments.

1 Like