Initial Values for MultiSelect

In using the multiselect when I bind to the ‘Initial Value’ to a collection nothing appears to be displayed/selected. I am able to bind a collection to the ‘Options’ and assign both values and labels for the control. Both the Initial Value and the Options bind to collections with the same collection layout (name, id, description) in the same order but with different values.
Is there any documentation on how to set the initial values of a multiselect tool and/or how should I can do this?

To set the initial values, you need to supply them in an array.

So, if your multi select holds the following values:

multi_select = [
{“display”: “Ohio”, “value”:34},
{“display”:“Kentucky”, “value”:21},
{“display”: “Washington”, “value”:18},
{“display”:“Florida”, “value”:12}
]

If you supply the following array in the initial value, it will initially select Florida and Ohio:

initialValues = [12,34]

Okay, but I don’t know the initial values at design time, I’m doing a API request to get a collection like
[
{“display”:“admin”, “value”:1},
{“display”:“super user”, “value”:2},
{“display”:“secure user”, “value”:3}
]

The full dataset is something like

[
{“display”:“admin”, “value”:1},
{“display”:“super user”, “value”:2},
{“display”:“secure user”, “value”:3},
{“display”:“company user”, “value”:4},
{“display”:“site admin”, “value”:5},
{“display”:“group admin”, “value”:6},
{“display”:“public user”, “value”:7}
]

The full listing is coming from REST call, selected values are also coming from a REST call.
I can get the full listing to show up and that works fine.
I can’t seem to get the initial/selected values to populate/show when the control loads are run time.

Nevermind, solved this with using the Rollup function.

1 Like

Awesome! Way to go!

To leave an answer for anyone that sees this later … You just need to supply the initial values as an array. So, you can do that with nocode formulas, or if they are coming as part of an API call that way.

For many scenarios, you will have a list of available values come from a separate API call, and then the specific record values supplies by a different API call.

This would be a scenario like editing a territory for a sales representative.

All of the available Territories come from one API call. Then, when you edit the record, you get the specific territories that the sales person already works in.

You will load the multi select with all of the options from the available territories, and then set the initial value to the Sales Reps specific territories that they already work in.

1 Like

@kevinwasie I was trying to follow your suggestion but I’m confused on where to put initial value
image

in options how do you display values in case you are not requesting data from the backend?