Dropdown Options from Text Array

Hello!

I have a database table with Retool usernames in one column ('usernames'), and an array of user specific options in another column ('options'). The 'options' data is stored as a text array (_text) in the format below:

["Option 1","Option 2,"Option 3"]

I have a query called fetchOptions

SELECT 'options'
FROM table
WHERE 'usernames' = {{ current_user.email }}

When previewing the output, I see the following:

options: 1 item

0: 2 items

0: "Option 1"
1: "Option 2"

I am struggling with the next step, which is applying this output as a list of options in a single-select dropdown component. I've implemented similar features albeit with slightly different logic in play, and there's some variable in this scenario that's throwing me for a loop.

For example, if I make my Data Source 'fetchOptions' and place '{{fetchOptions.data.options}}' in the 'Values' field, I see the following:

[""]

How would some of the savvier users here approach this efficiently?

Thanks in advance for your help!

1 Like

Hi there @pod2, and welcome to the forum!

One approach is to change your data source to {{ fetchOptions.data.options[0] }} and both your Values and Labels field to {{ item }}

That worked brilliantly! I hadn't realized I could manually enter my data source, as opposed to choosing a query from the dropdown.

Thank you very much for your help.

1 Like