What happened to my checkboxes? 

by | Jan 13, 2022 | Collaboration

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 are accelerating into the mobile world considering the amount of canvas area checkboxes require, 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 larger canvas area is available, hence the organization and layout constraints are different.  

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 can be straightforward. They can be split into a few major steps. 

Preparation of the DataCard 

  • Unlock the data card that you are changing to checkboxes.   
  • Within the form, add a blank gallery. (It will be outside of your form, so I find it best 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.) 

Set up your gallery and configure the checkboxes.  There are a few fields in this step. I start with the advanced properties of the checkbox.  Then I move to the settings for the gallery itself. 

  • 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. 

Now that we have the collection working and we can see it change as the boxes are selected and unselected it is time to clean up of the DataCard.  The drop-down field is no longer needed and can be deleted, and the final arrangement of the card layout can be completed.   

Oh no, when I deleted the drop-down, I now have a red circle with X on my DataCard. Don’t worry, this is a simple fix.  It just needs to be attached to the gallery now since the multi-select drop-down is no longer there for the DataCard to tie to.  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.  We will set it to be tied to the collection just created. 

The last and most important step is clearing the information from your gallery so it will not be there the next time a form is open. This is done in the integration with PowerApps and SharePoint. We go to the SharePoint Integration under advance, we need to add some code to the properties we find here. 

  • 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 last time it was opened. 

Once you get an understanding of the gallery and how the collection works it is a few steps to take the multi-select drop-down back to the favored checkboxes. 

Check out this PowerPoint for more: PowerApps-Checkboxes.