Description:
Create a Form with a Multi-Select Checkbox in Dataverse
Works with Microsoft office365
Solution:
- Begin by creating a Form control and add the multi-choice field from your Dataverse table. Keep in mind that for a multi-choice field, you need to ensure that the “Selecting multiple choices is allowed” toggle is enabled.
We would enter “BrowseGallery1.Selected” into the Items property of the Form to do this. To keep this tutorial simple, I am going to add a Combo Box control into the App and set its Items property to my Data Source, as well as set my Unique ID field as the field to Display.
Note that for the purposes of this tutorial, this Form is called “Form1“, my multi-choice field is called “Local Multi Choice“, my Dataverse table is called “Sample Issue Datas“, and my Combo Box control is called “ComboBox1“.Adding a Gallery into the DataCard
1. Insert a blank vertical Gallery into your App
2. Cut and Paste the Gallery into the multi-choice Data Card
3. You should end up with the below
4. Unlock the Data Card for your multi-choice field and copy the Choices expression onto a Notepad; we will need to use this expression shortly.5. Delete the default Combo Box in the Data Card. This is no longer required.
6. Note that doing so will result in errors in the Y property and Update property of the Data Card. For the time being, delete the expression in the Y property. We will deal with the Update property later
7. Insert a Checkbox control into the Gallery
8. Set the Items property of the Gallery to the Choices expression we copied earlier
9. Set the Text property of the Checkbox control to ThisItem.Value
10. Configure and format the Gallery as desired. For example, you may want to set the wrap count to 2 or 3 columns and adjust the Gallery size to fit neatly into the Form. See example below:
Expressions
1. On the OnSelect property of the Checkbox, enter:
Collect(
ColSelectedItem,
LookUp(
Choices('Local Multi Choice (Sample Issue Datas)'),
ThisItem.Value = ThisRecord.Value
)
)
2. On the Uncheck property of the Checkbox, use:
Remove(
ColSelectedItem,
LookUp(
Choices('Local Multi Choice (Sample Issue Datas)'),
ThisItem.Value = ThisRecord.Value
)
)
3. Set the Default property of the Data Card to ColSelectedItem
4. Set the Update property of the Data Card to ColSelectedItem
5. Select the Default property of the Checkbox control and enter:
If(
'Your Form'.Mode = FormMode.New,
false,
ThisItem.Value in ComboBox1.Selected.'Local Multi Choice'
)