Select value connected to state variable

Hello, firstly thanks for the data connection to controls,
I need guideline to connect a select control to a state variable.

thank you.

@Angel_Vittorio_Lopez hey!
Will this work as a guide? :slight_smile:

yes the thing is when the data comes through my api, the value doesn’t select the option

example, if in your state.someVariable comes with ‘option 1’ the control doesn’t select the ‘option 1’

1 Like

@Angel_Vittorio_Lopez, hello!
I’ll share my own idea on how to achieve this.
To load data into the select component you should do the following:

  1. use an HTTP request with the Get method to load the data from URL;

  2. Save Data to App State Manager and paste here code snippet:

{{}}.map(item => ({ label:, value: }))

now create a variable and set a name and type (in my example, it is a string) for the variable.
3) Open the Builder Tool, add here select component, open its settings. Find field “options” and add here a variable created in the 2nd step. To add variable just type {{ and you will see a menu with variables.

Also, don’t forget to set action that was created in 1st step on a root space on init. To do this, click on root space open it data settings, add an action created in the 1st step.

I used this API, and don’t forget to delete hardcode data from select component and replace it to the variable you’ve created in the step 2.

That should resolve the issue

I hope this helps

1 Like