Configure a choices column on portals

Makers can design basic forms and multistep forms to include choices columns defined in Microsoft Dataverse. This feature provides the ability for portal users to select multiple options while submitting data, and display views that include choices columns through lists.

Basic forms and multistep forms

You can design a basic form or an multistep form step in the website by using a Dataverse form that has a choices column to support the selection of multiple options. Website users can insert, modify, or clear the selection.

Choices column on a form.

Screen showing a list of outdoor activities being created. The user expands the Select or search options box and selects some activities from the list that appears. The selected activities appear at the top of the window. The user enters the letters C a m in the box, and then selects the option Camping when it appears. At the top of the window in the list of activities, the user selects the Close button next to one of the options to deselect it.

List

You can define a choices column in a Dataverse view to display the multiple options that are available for the record in a list. The choices column supports quick search by typing a keyword to filter the list.

Choices column on a list.

Note

Sorting a list by the choices column isn't supported.

Liquid

Developers can design the website by using Liquid to retrieve the records from a Dataverse table. Choices columns can be retrieved while the data is being queried by using fetchXML or an entity view.

{% for choice in record.ChoicesColumn %}
    {{ choice.Label }}
    {{ choice.Value }}
{% endfor %} 

Examples of choices for sample_outdooractivities values are shown in the following table.

Value Label
1 Swimming
2 Hiking
3 Mountain Climbing
4 Fishing
5 Hunting
6 Running
7 Boating
8 Skiing
9 Camping

Examples of contact table values are shown in the following table.

'fullname' column 'Sample_outdooractivities' column
Quinn Yarborough 1,9
Avery Orton 2
Yuri Maple 4
Ravi Mundy 2,3,8,9

Retrieve selected options by using fetchXML

{% fetchxml contacts %}
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
        <entity name="contact">
            <attribute name="firstname" >
            <attribute name="lastname" >
            <attribute name="sample_outdooractivities" >
        </entity>
    </fetch>
{% endfetchxml %}
{% for item in contacts.results.entities %}
{
    "First Name":"{{ item.firstname }}",
    "Last Name":"{{ item.lastname }}",
    "Outdoor Activities": [
        {% for choice in item.sample_outdooractivities %}
            {{choice.Label}},
        {% endfor %}
    ]
}
{% endfor %}

Retrieve selected options by using an entity view

{% entitylist id:page.adx_entitylist.id %}
{% for e in entityview.records -%}
    {
    "First Name":"{{ e.firstname }}",
    "Last Name":"{{ e.lastname }}",
    "Outdoor Activities": [
    {% for choice in e. sample_outdooractivities %}
        {{choice.Label}},
    {% endfor %}
    ]
    }
{% endfor -%}

Web API

Developers can use choices columns by using the Web API read, create, and update operations.

Read

GET \[Portal URI]\_api/contacts?$select=fullname,sample\_outdooractivities &$top=1

Response –

{
"value": [
    {
    "@odata.etag": "W/\\"1066412\\"",
    "fullname":" Quinn Yarborough ",
    "sample\_outdooractivities ":"1,9",
    "sample\_outdooractivities @OData.Community.Display.V1.FormattedValue":"Swimming, Camping"
    }
    ]
}

Create / Edit

Method – PATCH / PUT

\[Portal URI]\_api/contacts (guid)

Body –

{
"sample\_outdooractivities": "1,4,8",
}

Known issues

Choices control will not be available in basic and multistep form metadata to apply extra behavior modification logic or override the functionality of form fields.