web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Working with Checkboxe...
Power Apps
Unanswered

Working with Checkboxes in Form DataCard in both Form Mode New and Edit

(0) ShareShare
ReportReport
Posted on by 353

Looking for some ideas how to approach this. 

 

I use my form controls for both New Items and Editing Existing Items. 

I have a Form DataCard with a plain text control as the base field type. 

I added 7 checkboxes to the DataCard to allow for the user to select days of the week. 

schuess3_0-1626447689964.png

I then hide the plain text input control.

OnCheck or UnCheck I add or remove text values to a collection. 

I then set the base text input field (hidden) to Concat() the values from the collection separated by semicolons. 

schuess3_1-1626447897313.png

 

When creating New Items this method works fine and the saved value for the Parent field is something like:  

Monday; Wednesday; Friday; 

 

When the form is used to edit an item, I set the default of the check boxes to something like this: 

If(“Monday” in DataCardValue, true, false) 

This works fine to show the proper state of the check boxes. 

 

My dilemma occurs when the day or the week checkboxes get altered during the editing of the item. 

 

I am either not sure what to do with the Default property of the base text input, and or I am not sure how to allow changes to be made. 

 

Make Sense? How would you approach this situation? @mdevaney @R3dKap @RezaDorrani @rsaikrishna 

 

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @schuess3 

    Can a user check more than one box or is the selection of the days mutually exclusive?

  • schuess3 Profile Picture
    353 on at

    A user can check as many boxes as they want.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @schuess3 

    See @RezaDorrani 's video here https://www.youtube.com/watch?v=xUep4uud1BE  about converting a combobox to multiselect checkboxes.

  • R3dKap Profile Picture
    1,594 on at

    Hi @schuess3,

    What do you mean by "My dilemma occurs when the day or the week checkboxes get altered during the editing of the item."?

    Do you mean: how to handle the fact that the user can manualy change the text that's in the text input control and end up with something like "Mony; ednesday; Friday;"? Is that it?

    If that's the case, my answer is very simple: your text input should be disabled as it is automatically calculated according to your checkboxes. The checkboxes should be the only one used to change the content of the text input field. See what I mean?

  • schuess3 Profile Picture
    353 on at

    The checkboxes will be the only control visible and interacted with. The text input will be hidden.

     

    The dilemma is that the choices i made to build up a collection based on checkboxes and then save those selecctions as a text string works fine in New mode, but in the reverse (edit mode) where i need to not only populate the checkboxes to there proper states, but i also need to allow for the checkboxes to be changed. 

  • Verified answer
    R3dKap Profile Picture
    1,594 on at

    Ok, I get it...

    What I would do to make it work in edit mode is:

    • rebuild the colServiceDays collection from the field's text value when editing an item using this:
     ClearCollect(colServiceDays, RenameColumns(Split(TextInputField.Text, ";"); "Result"; "Day"))
    • then on Default property for the checkbox (and repeat it for each days' checkbox):
    "Monday" in colServiceDays
    • set the Default property of your text input field to this:
    Concat(colServiceDays; Day; ";")

    As you can see, the idea is that you always work with the same object: the colServiceDays collection.

    Give it a try and tell if this works...

  • schuess3 Profile Picture
    353 on at

    I am real close now. Thank you for your help.

     

    The only issue I am having is that the function to rebuild the collection on edit is rebuilding it without the semicolon. 

     

    ClearCollect(colServiceDays,RenameColumns(Split(DataCardValue12.Text,";"),"Result","Day")))

     

    It is using the semicolon to rebuild the collection, however on the rebuild it is not considering it part of the value.

     

    When a checkbox is checked

     

    Collect(colServiceDays,{Day:"Sunday;"})

     

    The semicolon is added, which is necessary to rebuild the collection.

     

    again, but on the rebuild, the collection row values no longer contain a ;

     

    Thoughts @R3dKap ?

  • R3dKap Profile Picture
    1,594 on at

    Hi @schuess3,

    Glad to see the progress...

    About the semicolon. Well, the semicolon must not be stored inside the collection. The collection should only have day names like:

     

    Monday
    Thursday
    Friday
    Saturday

     

    The semicolon appears within the text input field when using the Concat() function.

    And when the collection is recreated from the string containing days separated with semicolons, the Split() does the splitting at each semicolon. But inside the collection -> no semicolon is needed.

     

    Do you follow?

  • R3dKap Profile Picture
    1,594 on at

    Notice that the Concat() function does a good job as it does not add a semicolon after the last item... 😉

  • schuess3 Profile Picture
    353 on at

    So close, but I can't figure out what is wrong. When the form is opened in edit mode, the Text Field is blank and the Collection is empty.

    My OnVisible Property is

    If('Name of Form'.Mode<>FormMode.New,ClearCollect(colServiceDays,RenameColumns(Split(DataCardValue12.Text,";"),"Result","Day")))

     Default Value of Text Input

    Concat(colServiceDays, Day, ";")

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 759 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 310 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 228

Last 30 days Overall leaderboard