@RezaDorrani & @mdevaney created wonderful step-by-step tutorials on building multi select checkboxes in a Canvas App Form for a SharePoint list. A question I have seen raised on the Forums and in the comments section for both methods, is how to replicate this functionality for Dataverse.
Reza Dorrani video walkthrough: https://youtu.be/xUep4uud1BE
The below walkthrough follows the same general instructions as provided above, but has been tailored with specific changes to accommodate Dataverse Choice Columns / Option Sets (whether Local or Global). I would recommend diving into those tutorials thoroughly before proceeding.
Initial set up
1. Create a Form control and include the multi-choice field from your Dataverse table. Note that a multi-choice field requires that the “Selecting multiple choices is allowed” toggle is set to On.
2. I want my Form to be populated with information based on a selected record. Typically, 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, my 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:
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' )
If you like this blog, please give it a Thumbs Up.