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 / 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
    153,117 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
    153,117 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.

     

  • WarrenBelz Profile Picture
    153,117 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.

     

  • 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

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 765 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 272

Last 30 days Overall leaderboard