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 / Pass Checkbox Text to ...
Power Apps
Answered

Pass Checkbox Text to a collection when checked and nothing when unchecked

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm very new to Power Apps.  I created a form in Power Apps to simply collect data and pass it through Power Automate into Azure DevOps board where it opens a record and sends an Email to the person who filled out the form.  I can pass data successfully and create a ticket in ADO and send an email to the user who filled out my form. I'm purposely not using any SharePoint Lists.  This form it simply to collect and pass data and not to retain it.

 

My problem is with checkboxes on my form. I have quite a few so I am starting with just two checkboxes for SLA.  I have one for Standard and one for extended and they are labeled as such.  I'm also using Collections to collect the data to pass to Power Automate.

 

I would like to have the text of the checkbox for SLA collected when it's checked and when it's unchecked to NOT collect anything. Basically, pass no data.  Currently, whether it's checked or not it will still show the Text of both checkboxes even though the Boolean value shows false.

 

Both of my checkboxes are configured with the below screenshot:

kjacob_0-1691190830782.png

 

kjacob_2-1691191059425.png

 

In my collection ( colRequest) I have listed:

StandardSLA: standardSLA.Text,

ExtendedSLA: extendedSLA.Text

 

My collection starts like this:

 

ClearCollect(
colRequest,
{

 Record: title.Text,

StandardSLA: standardSLA.Text ..... 

 

I tried using the value of those checkboxes and it does show true when selected and false when not selected. I want to figure out how to have it show the string "Standard SLA" when chosen (true) and basically nothing when not chosen (false).

 

I'm not using Gallerys but containers. In my container I have the two checkboxes for above.  

 

I hope this makes sense.  Any advice would be appreciated. 

 

Thanks

 

 

 

Categories:
I have the same question (0)
  • elseb Profile Picture
    774 Moderator on at

    Hi,

     

    I hope i understood your question 🙂

     

    would that work for you? to understand what I'm suggestion put that in a text label and check functionality if thats what you need you can use it in patch:

    If(Checkbox1.Value = true, Checkbox1.Text, "nothing")

     

     

    Seb

  • kjacob Profile Picture
    Microsoft Employee on at

    Thank you. Your suggestion worked but I was hoping to avoid adding a label next to the checkbox as a control and use the checkbox itself. (I have 60 checkboxes to set up on this form).

     

    I tried to add the Patch function to my collect statement, but I still need to learn more about that. I couldn't figure out the syntax needed to get the red underlines to go away. 

     

    With that said, I have gotten further than I have before, and I am now able to pass a string message identifying whether SLA was selected or not selected successfully through my Power Automate flow to ADO.  

     

    I modified my collect statement to accept the labels instead of the checkbox.Texts directly.

     

    ClearCollect(
    colRequest,
    {
    Title: Title.Text,
    Description: Description.Text,
    Contact: contact_Name.Text,
    EmailContact: contact_Email.Text,
    FolderLocation: URL.Text,
    DueDate: datePicker1.SelectedDate,
    StandardSLA: labelStandardSLA.Text,  (Originally - standardSLA.Text which was the name of the checkbox itself)
    GeoPolReview: labelGeoSLA.Text

    }
    );

     

    Label:

    kjacob_0-1691439896492.png

     

    Checkbox:

    kjacob_1-1691439940741.png

     

    If there is a way to avoid adding labels in order to get my checkboxes to work in the same way, I would love to hear it.

     

    🙂

     

  • elseb Profile Picture
    774 Moderator on at

    oh, sorry it's a misunderstanding I only suggested the label because you sked to pass the textbox text 🙂 if you have a lot of checkboxes I have a better solution for you where you'll be able to store all of them in single text column. I will edit this post in a minute and drop you some code.

     

     

    right so the patch looks like this:

     

    textColumn: checkbox1.Value & "," & checkbox2.Value & "," & checkbox3.Value & "," & checkbox4.Value & ",",

     

    this will save a series of true/false separated by commas.

     

    to retrieve it back into the checkboxes you pull the column value into a variable e.g. varChecklist then in each of the checkbox default value put:

     

    If(!IsBlank(varChecklist), If(Index(ForAll(Split(varChecklist, ","), {Result: ThisRecord.Value}), 1).Result = "true", true ,false))

     

     

    the number 1 in this code is the value location so if you have true,true,false,false number one will be first true, nr2 will be second true and so on.

    this code technically will work without the !IsBlank but index will not like it when the var will be empty.

     

    this solution will save you a lot of columns if you're using a lot of checkboxes.

     

    ps. you can use the same pattern to display the label value you need so in the text of a label you can put:

     

    If(!IsBlank(varChecklist), If(Index(ForAll(Split(varChecklist, ","), {Result: ThisRecord.Value}), 1).Result = "true", "Standard SLA selected","Standard SLA not selected"))

     

    hope this helps.

     

    Seb

  • kjacob Profile Picture
    Microsoft Employee on at

    Thank you! 

     

    I have some questions. Does the variable need to be global? Or do I create in my ClearCollect statement somehow? Or do I make it in a label that goes over the checkboxes for control? I guess I'm not quite sure where to create the variable Checklist. I definitely like your solution and want to try it.  Example: I have 5 checkboxes that someone can choose from (either all or one).  Do I put a label around those 5 checkboxes and create a variable there?  Sorry, I'm super new to Power Apps.

  • elseb Profile Picture
    774 Moderator on at

    Hi,

     

    Variable can be global and local.

    You create the variable when acquiring the data record I assume you're clicking a button or an icon inside the gallery to select the record you want to view, you can add 

    Set(varChecklist, ThisItem.checklist_column);

     

    then in the fist checkbox default you put:

    If(!IsBlank(varChecklist), If(Index(ForAll(Split(varChecklist, ","), {Result: ThisRecord.Value}), 1).Result = "true", true ,false))

    second:

    If(!IsBlank(varChecklist), If(Index(ForAll(Split(varChecklist, ","), {Result: ThisRecord.Value}), 2).Result = "true", true ,false))

     

    and so on.

     

    to save the values of the checkboxes whatever action button or icon you're using to save your edits OnSelect property put:

    Patch(
     splist_name,
     Coalesce(
     LookUp(
     splist_name, yourRecordId = selectedRecord.yourRecordId
     ), 
     Defaults(splist_name)
     ),
     {checklist_column: checkbox1.Value & "," & checkbox2.Value & "," & checkbox3.Value & "," & checkbox4.Value & ",",
     }
     )

     

    splist_name - name of your sharepoint list

    yourRecordId - a value in the column that you will locate the record with (can be system created "ID" column

    slectedRecord - you need to point to the record you selected (i usually do Set(varSelectedItem, ThisItem) in OnSelect of the gallery)

    checkllist_column - text column in which you will store your string with checkbox values

    checkbox1/2/3/4 - names of your checkbox controls.

     

    I don't use forms but i assume that if you add the patch above into the same action and keep the form.updates they will clash so you'd have to remove the checkboxes from the form and just chuck them in the root of the screen above the form or container or something.

     

    you may have errors when you delete them from the cards because forms elements depend on each other for positioning as far as i remember but most you can just delete.

     

    If i was in your position i would sump the forms and just use patch and place the controls yourself, total freedom and control over the design of your apps.

     

    Anyways, if you need any more clarification or help give me a shout 🙂

     

    good luck!

    Seb

  • kjacob Profile Picture
    Microsoft Employee on at

    Thank you. I'll look through this. I saw that Patch suggestion before but I'm not using any SharePoint lists.  I also have my checkboxes in a container and not a gallery. But I'm thinking now they need to be in a gallery.   I'll play around with your suggestions and see if I can get that to work. Your original suggestion did help though, and I can always add a label as a control for my checkboxes and make it invisible if I have to. 


    Thanks again.

  • elseb Profile Picture
    774 Moderator on at

    You don’t need to put the checkboxes in the gallery. I’ve only mentioned the gallery because this is most likely the way you selecting your records. also if you’re not using the splist what are you using as a database?

     

    and my original suggestion was a misunderstanding it may work but it’s not a good choice, you should check the value of the checkbox and patch whatever you need based on the condition if that value is true do one thing and if not do the other.

     

    seb

  • kjacob Profile Picture
    Microsoft Employee on at

    I'm not pulling from a DataSource. The form I'm creating is to simply gather data from the user and pass it through a Power Automate flow, I setup, to Azure DevOps boards to open a ticket and send out an email to the user. This part works.

     

    I am using collections in Power Apps so that I have a place to temporarily put the collected data from the user.  The titles or descriptors in my collections always remains the same and I have them referencing either an input field or checkbox in my Power Apps form. For example: Title: inputTitle.Text  - I will always expect a string value here and once the user hits the submit button on my form it sends the information the user entered in that field through to ADO. 

     

    My challenge is the checkboxes. 

    For example:

    The user has to choose first a "Type item" (that's one checkbox.) Then the user has five options to choose from after that and they can choose all or "none" of the checkboxes for that Type Item. I included a visual down below. My collection title fields will always be there, but I was hoping I could avoid showing anything when the checkbox isn't checked.  

     

    kjacob_0-1691613820703.png

    I appreciate all your help on this.  I've been looking to find solutions, but everything involves SharePoint lists which I just don't use. If I do figure this out, I will certainly share it in case anyone else has a similar struggle.

     

    -K

     

     

     

     

     

     

  • Verified answer
    elseb Profile Picture
    774 Moderator on at

    ooh ok,

     

    ClearCollect(colRequest,
    {option1: If(Checkbox1.Value = true, "checkbox 1 selected", "checkbox 1 not selected"),
    option2: If(Checkbox2.Value = true, "checkbox 2 selected", "checkbox 2 not selected")})

     

    hope that helps 🙂

    Seb

  • kjacob Profile Picture
    Microsoft Employee on at

    The above worked. I'm sure it's unconventional and probably not best practices but it worked for what I needed to do. I'll post below for anyone else who has the same problem.

    Summary:

    • I'm NOT using SharePoint lists (this is on purpose).
    • The only purpose of my power app is to gather data to pass through a Power Automate flow (JSON file) to Azure DevOps. 
    • My SOURCE is this form.
    • I'm not using Galleries. All my info is sectioned out into containers.
    • I have standalone checkboxes in their perspective containers.

     

    I have multiple checkboxes where the first level is unique, but the second level is a repeat for each unique first level.

     

    All my code is in the Submit button.

    I have a colRequest collection and then collections for each first level choice.

     

    My code looks similar to this (In Submit button):

    ClearCollect(
    colRequest,
        {
           Title: title.Text,
            Description: description.Text,
            Contact: contact_Name.Text,
            EmailContact: contact_Email.Text,
            FolderLocation: URL.Text,
            DueDate: datePicker1.SelectedDate,
            
            Other: otherLabel.Text,
            OtherLabel: otherTextInput.Text, <- First level
            OtherLogos: colLogos, <-This here is a collection of 2nd level checkboxes
     
    }
    );

     

    ClearCollect(
    colLogos,
    {
         None: If(CheckboxNone.Value=true, CheckboxNone.Text,"None"), <--I'm debating on even keeping this one
         GP: If(Checkbox1.Value=true,Checkbox1.Text," "), <--I pass an empty string to satisfy my JSON file in Power Automate
         Ultimate: If(Checkbox2.Value, Checkbox2.Text," "),
         PCGP: If(Checkbox3.Value=true,Checkbox3.Text," "),
         EAPlay: If(Checkbox4.Value=true,Checkbox4.Text," ")
    }
    );

     

    With the above I can uncheck or check my checkboxes and it sends what I checked or didn't check to Azure DevOps board.

     

    Thanks again for all your help!! 🙂 

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard