Difficulty setting selected value of multiple select

Hello,

I am having difficulty setting the selected value of a multiple select on page load. The value that I want to set comes from database query as “service_name” under an array of “services”.

I could set the selected value if I choose query_user_data.data.services[0].service_name but it only set the first value and not all.
query_user_data.data.services gives me [object Object] so that didn’t work either.

I am using select2, if that’s relevant.

I’m not an expert (3-4 month old) but your matter seems familiar.
Can you share screenshots of the API action doing the query and of the component in the App Structure side where you fetch your services dynamic data?

Hello Fred, thanks for reaching out.
The names are slightly different from what I wrote above, but anyway:

Query:

Structure:
image

I am not getting what you are trying to accomplish, sorry. Do you want to list an array of ‘services’ or display one specific service on your page?
Could you explain further and/or share the result you see on the page?

Basically I need “ser_name” as an array [‘service a’,‘service b’,‘service c’ ] instead of an array of “services” containing ser_names, if that makes sense.

I managed to get it to work by creating a repeat (referencing “services”) and adding “ser_name” to an array component in a page flow. Then having the selected value of my select2 referencing that array component. I feel like there is a way simpler way though.

1 Like

I was going to suggest repeat.
Have you seen this tutorial page, scroll to after screenshot66: https://docs.wappler.io/t/nested-repeat-regions/5165