# setOptions

## Description

Allows users to set a value to a component.

## Input / Parameter

| Name         | Description                                                                                                            | Input Type  | Default | Options | Required                       |
| ------------ | ---------------------------------------------------------------------------------------------------------------------- | ----------- | ------- | ------- | ------------------------------ |
| component    | The name of the component.                                                                                             | String/Text | -       | -       | Yes, if componentId is not set |
| componentId  | The component ID (for components in FlatList item)                                                                     | String/Text | -       | -       | Yes, if component is not set   |
| data         | The id of the component.                                                                                               | Array/List  | -       | -       | Yes                            |
| valueField   | The name of the attribute from the list of options (from data parameter) to be as the value of the dropdown options.   | String/Text | -       | -       | Yes                            |
| displayField | The name of the attribute from the list of options (from data parameter) to be as the display of the dropdown options. | String/Text | -       | -       | Yes                            |

## Output

| Description                        | Output Type |
| ---------------------------------- | ----------- |
| Returns the formatted information. | Object      |

Note: The component will be updated to show the value that has been set to it.

### Object

| Key     | Description                                                             | Output Type |
| ------- | ----------------------------------------------------------------------- | ----------- |
| success | Boolean value to denote whether the function was executed successfully. | Text        |
| message | The message to print.                                                   | Text        |
| data    | Any additional message or data to print.                                | Text        |

## Example

In this example, we have a button (in blue) that when clicked will populate the dropdown of the component.

### Steps

1. First, we drag a button and a dropdown input onto the Editor.

   ![](/files/VD1kcqUJdz85EpAKbzVw)
2. Select the button and under the 'Actions' tab, drag the `Component.setOptions` into the flow for the button.

   ![](/files/0fwRT7QBLTx5mj1RxZEq)
3. Under the inspector for this function, select the component whose dropdown you would be populating, which in this example is `Dropdown411`, and then fill in valueField and displayField

   ![](/files/a1m4AannDVT0liHBTmRr)
4. Add the function `Conversion.toList` in the 'data' parameter using the 'function' parameter type.

   ![](/files/wx0UBOQdSa1yv5ipjJho)
5. Then add `Conversion.toObject` inside each parameter of the `Conversion.toList` function. The object must follow valueField and displayField that has been set

   ![](/files/8D43x7PhRYB7IuLEmNjg)

### Result

1. Save and preview your app.
2. Now when you click the button, it will set the dropdown of Dropdown411.

## Links

### Related Information

See also:

* Components
  * [Dropdown](/emobiq-client/006-actions-and-visual-logic/action-reference/react-native/component/setoptions.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/react-native/component/setoptions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
