otnielba
otnielba

Reputation: 53

Can't set selected options in Slack dialog select element

I am working with dialogs in Slack and select lists. I am trying to set the selected_options default value but I am still getting the placeholder.

{
    "label": "Are these notes private?",
    "type": "select",
    "name": "private_notes",
    "optional": "true",
    "hint": "Public notes are automatically published to #heartbeat",
    "options": [{'label': 'yes', 'value': 'yes'}, {'label': 'no', 'value': 'no'}],
    'selected_options': [{'label': 'no', 'value': 'no'}],
}

result: enter image description here

Upvotes: 1

Views: 1831

Answers (1)

Erik Kalkoken
Erik Kalkoken

Reputation: 32852

The selected_options property only works for dynamic select menus, not for static ones. And btw. there no point in setting multiple defaults for a select menu. It can only have one default.

To set a default value for a static select menu use the property value.

Example for setting yes as default:

{
    "label": "Are these notes private?",
    "type": "select",
    "value": "yes",
    "name": "private_notes",
    "optional": "true",
    "hint": "Public notes are automatically published to #heartbeat",
    "options": [{'label': 'yes', 'value': 'yes'}, {'label': 'no', 'value': 'no'}]
}

Also see here for reference in the official documentation.

Upvotes: 3

Related Questions