Multi Select metadata field
Multi Select metadata field
A metadata field of type multiSelect
is displayed to a user as a dropdown
list. The user can select multiple items from the list.
Create a multiSelect
field
A multiSelect
field can be added to a metadata template either when creating
a metadata template, or when updating a
template with the addField
operation.
The required attributes for a multiSelect
field are a type
, a displayName
,
a key
, and a list of options.
{
"scope": "enterprise",
"displayName": "Contract",
"fields": [
{
"type": "multiSelect",
"key": "box_entity",
"displayName": "Box Entity",
"description": "The Box entity that this contract belongs to",
"hidden": false,
"options": [
{"key": "Box, Inc"},
{"key": "Box.com (UK) Ltd."},
{"key": "KK Box Japan"}
]
}
]
}
Optionally a description
can be provided that is shown to a user in the UI,
and the field can be set to hidden
to hide it from users in the web and mobile
apps.
Update a multiSelect
field
A multiSelect
template field can be updated by updating the
template it belongs to. Updates to templates happen through
operations to ensure that any template that is already assigned to a file or
folder is updated as well.
Change basic field values
When updating a multiSelect
metadata field one of the possible operations is
the editField
operation which can be used to change the field's key
,
displayName
, description
and hidden
values.
[
{
"op": "editField",
"fieldKey": "box_entity",
"data": {
"displayName": "Box Entities",
"key": "box_entities"
}
}
]
Add an option
Adding an option to a multiSelect
field can be achieved through the
addMultiSelectOption
operation. The operation expects the fieldKey
to be set
to the key of the enum
field to change, and a data
object with the key
of
the new option to add.
[
{
"op": "addEnumOption",
"fieldKey": "box_entity",
"data": {
"key": "Box (NL) BV"
}
}
]
The list of options should now be as follows.
...
"options": [
{"key": "Box, Inc"},
{"key": "Box.com (UK) Ltd."},
{"key": "KK Box Japan"},
{"key": "Box (NL) BV"}
]
...
Reorder options
Reordering the options in an multiSelect
field can be achieved through the
reorderMultiSelectOptions
operation. The operation expects the fieldKey
to
be set to the key of the enum
field to change, and an multiSelectOptionKeys
array with the keys of the options in order.
[
{
"op": "reorderMultiSelectOptions",
"fieldKey": "box_entity",
"multiSelectOptionKeys": [
"Box, Inc",
"Box.com (UK) Ltd.",
"Box (NL) BV",
"KK Box Japan"
]
}
]
The list of options should now be as follows.
...
"options": [
{"key": "Box, Inc"},
{"key": "Box (NL) BV"},
{"key": "Box.com (UK) Ltd."},
{"key": "KK Box Japan"}
]
...
Edit an option
Editing an option of an multiSelect
field can be achieved through the
editMultiSelectOption
operation. The operation expects the fieldKey
to be
set to the key of the enum
field to change, and an multiSelectOptionKey
to
be set to the key of the field option. Finally, it expects a data
object with
the new key
of the field option.
[
{
"op": "editMultiSelectOption",
"fieldKey": "box_entity",
"multiSelectOptionKey": "Box (NL) BV",
"data": {
"key": "Box.nl BV"
}
}
]
The list of options should now be as follows.
...
"options": [
{"key": "Box, Inc"},
{"key": "Box.nl BV"},
{"key": "Box.com (UK) Ltd."},
{"key": "KK Box Japan"}
]
...
Remove an option
Removing an option from an multiSelect
field can be achieved through the
removeMultiSelectOption
operation. The operation expects fieldKey
to be set
to the key of the enum
field to change, and an multiSelectOptionKey
to be
set to the key of the field option to remove.
[
{
"op": "removeMultiSelectOption",
"fieldKey": "customer_state",
"multiSelectOptionKey": "KK Box Japan"
}
]
The list of options should now be as follows.
...
"options": [
{"key": "Box, Inc"},
{"key": "Box.nl BV"},
{"key": "Box.com (UK) Ltd."}
]
...