Through my process with PowerApps forms, I found it curious that checkboxes are not a standard field. Although I can understand the reasoning as we accelerate into the mobile world, considering the amount of canvas area checkboxes required, they are still very much a desired field type to be used in forms.
Checkboxes have been around and used in all sorts of forms, from excel to InfoPath. However, SharePoint Online and PowerApps use a multi-select drop-down instead of checkboxes. Although this might be a good option for mobile devices because of canvas constraints, checkboxes are still preferred in environments where a larger canvas area is available; hence the organization and layout constraints are different.
Here's the good news: the PowerApps default multi-select drop-down can be configured back into the checkboxes. It just takes getting used to a gallery to contain the information to be written to the SharePoint list at the time of form submission. Once you get the idea of a gallery, the steps are straightforward. We've broken it down into a few major steps below.
Preparing the DataCard
- Unlock the data card that you are changing to checkboxes.
- Within the form, add a blank gallery.
- This will be outside of your form, so it's easiest to cut the gallery and paste it into the data card you are changing. Adjust the size to fit your card. Of course, renaming your gallery is a good idea if your form is going to have more than one data card with checkboxes.
- This will be outside of your form, so it's easiest to cut the gallery and paste it into the data card you are changing. Adjust the size to fit your card. Of course, renaming your gallery is a good idea if your form is going to have more than one data card with checkboxes.
Gallery Setup and Checkbox Configuration
There are a few necessary configurations in this step. It's best to start with the advanced properties of the checkbox and then move to the settings for the gallery itself as follows:
- Checkbox fields:
- OnCheck
- OnUncheck
- Default
- Text
- Gallery settings:
- Items – select the items value of the multi-select drop-down and update the gallery items setting with that code. Example: Choices(‘Academic Dishonesty’.’Notification Method’)
- Wrap count – the number determined by area on DataCard and layout design desired
Once these have been configured, you can view them in the collection of the PowerApps form to verify everything is working. With the collection working, and we can see it change as the boxes are selected and unselected, we can move on to the next step.
DataCard Cleanup
The drop-down field is no longer needed and can be deleted, and the final arrangement of the card layout can be completed. But wait... Oh no! When the drop-down is deleted, a red circle with "X" appears on the DataCard! Don’t worry, there's an easy fix for this issue. The DataCard just needs to be attached to the gallery since the multi-select drop-down is no longer there for it to tie into. There are usually three errors on the card. Two need to be updated to connect with the checkbox for the y-value, and the third is the updated value of the card. It needs to be tied to the collection just created.
The last and most important step is clearing the information from the gallery, so it will not be there the next time a form is open. This is done in the integration with PowerApps and SharePoint. In the SharePoint Integration under advance, some code will need to be added to the properties:
- OnNew –
Example:
ResetForm(FormNew);
Clear(colMethod);
NewForm(FormNew);
- OnEdit –
Example:
Refresh(‘Academic Dishonesty’);ResetForm(FormEdit);
Collect(colMethod,’Academic Dishonesty’.’Notification Method’);
ClearCollect(colMethod,SharePointIntegration.Selected.’Notification Method’);
EditForm(FormEdit);
- OnView –
Example:
Refresh(‘Academic Dishonesty’);
ResetForm(FormView);
Collect(colMethod,’Academic Dishonesty’.’Notification Method’);
ClearCollect(colMethod,SharePointIntegration.Selected.’Notification Method’);
ViewForm(FormView);
This code will ensure when a form is either created, edited, or viewed that it will show correct values from the SharePoint list and not contain stale items left in the gallery the last time it was opened.
With an understanding of the gallery and how the collection works, it's only a few steps to convert the multi-select drop-down back into the favored checkboxes.
Check out this PowerPoint for more: PowerApps-Checkboxes