How To Populate Dropdown from Data Resource

I have a data resource and I would like to populate a drop down control with the .Name and .ID fields from all the records in the resource.

How do I do that? A link to docs or video is appreciated!

Once you have the data from your data resource in a data variable – let’s say its name is myData, you can use the MAP formula function to transform the data.

The dropdown requires an array of objects with label and value, so your formula for the Dropdown options would look like MAP(data.myData, {label: item.Name, value: item.ID}) (the curly braces allow you to create an object directly in the formula).

4 Likes

Harri,
Thanks for tagging me on this, and it worked perfectly!!

2 Likes

Could you please ad this to the interface somehow? I had to search all over to figure out how to populate a dropdown which seems like a pretty common use case. The error message I had was baffling (something about how a list of objects with 2 properties was incompatible with a list of objects with 2 properties…hehe.)

Hi, we have the info in the tool tip for the list (like in most other cases), but I agree that it can sometimes be quite hidden from users.

image

The problem here is that we have to balance between showing enough information and not cluttering the user interface too much since there’s already quite a lot of stuff on display.

Another way to check what a component needs as property is to use the basic static binding option and look what our binding editor suggests. That should give an indication of what you need if you want to work with Formulas. With Dropdown I mean this modal that opens when you change the binding:

This is helpful, thanks!