Populating a select component from a query, how can I auto select the first item?

I am using a JSON API query to populate a select component called selectCustomer. After it has finished populating the list I would like the first item in the list to be selected. I have tried setting the Default value property of the select component to {{selectCustomer.labels[0]}} but it is not working. Any suggestons please? I am new to Retool.

hey @markhammondmambu !

from what you've explained, I think you need to have selectCustomer.data.idField['0']
where idField is whatever you have for the value of your select component

if you look on my image, I have a query called individualVacationData (like your selectCustomer query) where I am displaying the name (label) but the value for the select component is the employee_id. For that reason, I have to have the default value as employee_id

does that make sense?

2 Likes

Thanks David, that makes perfect sense and I now have it working. Much appreciated!

1 Like