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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / checkbox and relate fu...
Power Apps
Unanswered

checkbox and relate function

(0) ShareShare
ReportReport
Posted on by 11

Hi,

I am using checkbox inside a gallery and when a checkbox is checked, it stores its value in CDS using relate function but I have found out that it unchecked itself .

Any solutions on how to retain its checked state.

Thanks

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,399 Most Valuable Professional on at

    @Rohit03 ,

    If the checkbox is not "bound" (its Default is not a field in the collection or list the gallery is based on), then any code run from inside the gallery will reset it to its Default value (which I suspect is false). The only way to avoid this is to have a field in the data (in a collection you simply add a Boolean field and patch the checkbox value to it when changed), then have the Default of the checkbox bound to this field.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • DavidZoon Profile Picture
    738 Most Valuable Professional on at

    Hi,

    You have to set the default value of your checkbox test if your records are allready related

    If you are viewing Table1 item, stored in a variable and your gallery is showing Table2 items, you can set the default value to :
    VarTable1.Table1 in ThisItem.Table1.Table1

    Be carreful with this, because default value change can trigger oncheck and onuncheck events

  • Rohit03 Profile Picture
    11 on at

    Hi, can you please provide the sample code.

  • WarrenBelz Profile Picture
    155,399 Most Valuable Professional on at

    @Rohit03 ,

    Happy to correct your attempt at it - please post in Text using all of your values including where you are using it. You also need a collection as the data source.

  • Rohit03 Profile Picture
    11 on at

    Hi,

    I have a checkbox inside a gallery and its value is from courses table, when a checkbox is checked ,I want to write all the checked values in another table(tags) in CDS and it is working fine but the problem is that whenever I checked the checkbox , it unchecked itself but I want the checkbox to retain its checked state when it is checked.

    So far I am not able to find solutions to this problem.

     

    ch.PNG
    chk1.PNG
  • WarrenBelz Profile Picture
    155,399 Most Valuable Professional on at

    @Rohit03 ,

    Not sure why you re-posted your original question - if you have a collection for the gallery Items, use AddColumns to add the extra field, then Patch the checkbox value to it OnCheck and OnUncheck. The Default of the Checkbox is then ThisItem.YourNewFieldName. I just needed your structure and field names and you will understand the code better if you attempt it first.

  • Rohit03 Profile Picture
    11 on at

    I have tried adding a collection when a checkbox is checked which is inside a gallery, however in a collection there is only the last selected value. How can I get all the multiple selected values. There is only one checkbox in a gallery.

     

    one.png
    two.png
  • DavidZoon Profile Picture
    738 Most Valuable Professional on at

    If your collection contains only one item with More than one checkbox is checked :

     

    Maybe you use clearcollect() function in your checkbox (ClearCollect : clear the collection and add new records)

    Use collect() instead, to add a record to your collection and elsewhere, when you need to flush the collection, use clear()

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 846

#2
Valantis Profile Picture

Valantis 532

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard