Overview:
We implemented several Power Apps forms (customized SharePoint Forms) for a consulting firm based out of Alpharetta, Georgia, United States. When we customize our SharePoint form having a choice column, Power Apps represent the choices as a dropdown. For one of the forms we implemented, the requirement was to display checkboxes instead of a dropdown list for a choice column. So, how can we achieve this requirement? Let’s get started!
-
Open your customized SharePoint Power Apps form.
-
We need to add Checkboxes in the same data card as the dropdown. To add a
checkbox, go to the insert menu and add a checkbox. Add checkboxes based on the # of choice value from the dropdown.
-
Now, we need to create one group for all checkboxes. In this group add
default property using the below code.
Self.Text in DataCardValue2.SelectedItems.Value
-
For each Checkbox, we need to execute the below piece of code on both "OnCheck" and "OnUncheck" events. Add the following code to the "OnCheck" and "OnUncheck" events. The code
is same for both the events for all the checkboxes.
ClearCollect(ddtocb, If(Checkbox1.Value,Checkbox1.Text), If(Checkbox1_1.Value,Checkbox1_1.Text), If(Checkbox1_2.Value,Checkbox1_2.Text), If(Checkbox1_3.Value,Checkbox1_3.Text), If(Checkbox1_4.Value,Checkbox1_4.Text), If(Checkbox1_5.Value,Checkbox1_5.Text), If(Checkbox1_6.Value,Checkbox1_6.Text), If(Checkbox1_7.Value,Checkbox1_7.Text), If(Checkbox1_8.Value,Checkbox1_8.Text), If(Checkbox1_9.Value,Checkbox1_9.Text), If(Checkbox1_10.Value,Checkbox1_10.Text), If(Checkbox1_11.Value,Checkbox1_11.Text) ); ClearCollect(ddtocb,Filter(ddtocb,!IsBlank(Value)))
-
Now, select dropdown and open the DefaultSelectedItems property.
Pass collection created in the above step using the following code snippet.
-
Select final Data Card and
change Update property using the following code snippet.
If( IsEmpty(ddtocb),ThisItem.'<Field Name>',DataCardValue2.SelectedItems)
-
At last, change the dropdown’s visible property to make it false.
Conclusion:
This is how we can convert our dropdowns to checkboxes.
If you have any questions you can reach out to our SharePoint Consulting team here.
No comments:
Post a Comment