Multiselect default value not loading

The values of the multiselect are saved correctly in the database: {"AI introduction","Business rule"}

but when loading, nothing is displayed.



Welcome to the forum!
Try removing the [0] as seems to already be an array

removing the [0] change nothing :frowning:

Can you post or share the actual data for ?


So you have an array of arrays.....and you only want to show qc_issue in the drop down...
You could try using',')

no good :frowning:

is it possible for when you are retrieving the data to use UNNEST for the fields? Seems that you are storing them as an array so if you use UNNEST it should make things easier to render

1 Like

Hey @Sebastien! Are you still working on this? :slight_smile: Let me know if you still have any questions!

And thanks for jumping in here, as always, Scott :handshake:

Hi Victoria, yes we still on this.

As a temporary solution, we are displaying the value in text below the multi-select box.

Displayed as {"AI Introduction", "Business rules"}


Ah, got it. So it looks like your data (msginfo.qc_issue[0]) is returning this string:

"{"AI introduction","Business", "Hi"}"

The multiselect component expects an array of strings like:

["AI introduction","Business", "Hi"]

I was able to convert "{'AI introduction','Business', 'Hi'}" into the array and use it in a multiselect by splitting up the string, removing all the symbols (which were conveniently located at every even index) by doing this:

{{"'").filter((_, i) => i % 2 == 1) }}

Yours multiselect value could look like this:

{{ msginfo.qc_issue[0].split("'").filter((_, i) => i % 2 == 1) }}

Let me know how this works for you or if you have any questions at all!

1 Like

Did you try Scott's suggestion of unnesting the arrays in your query? My understanding of Postgres arrays (having not used them, granted) is that they're not really meant to be selected in their entirety. You either select elements from that array or you unnest it into separate rows. Otherwise you get a direct string copy of the array including the brackets and have to do a bunch of annoying string manipulation.

Check out example #5 here PostgreSQL UNNEST() Function With Examples - CommandPrompt Inc..

{{[0].split('"') }}