Drop down that reads dynamically from google sheets

Hi @ppatel!

You might have an array of objects here, which is a different data structure than SQL will return. Does this post help with this? How to prefill the content of dropdown from a query? - #6 by alex-w

Copying here for convenience :grin:
Some queries (usualy SQL based ones) return data as an object of arrays like this:
{ key1: [val, val], key2: [val, val] }

Which would make the selection of all of the values in an array easy as shown above, queryName.data.key1.

Many other data sources return an array of objects like this:
[ { key1: val, key2: val }, { key1: val, key2: val } ]

For this, you could either get the array of all of a certain value by using the .map() JS method, or converting it to an object of arrays using our helper function formatDataAsObject() (thereโ€™s also the opposite as formatDataAsArray). That would look like either:

queryName.data.map(d=>d.key1)
or
formatDataAsObject(queryName.data).key1

1 Like