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 / Update CheckBoxes Base...
Power Apps
Answered

Update CheckBoxes Based on Change in Another CheckBox

(0) ShareShare
ReportReport
Posted on by 5,331 Moderator

I have Gallery1, which is display content from a SharePoint list of Addresses.

An individual may be on the address list once or several times, as some people may own multiple residences and move from place to place - such as 'snow birds'.

The SP List has an 'Active_Address' column (Single line of Text, with 'Yes' or 'No' as the content; default is 'No'.

Gallery1 has CheckBox1, in which is ThisItem.Active_Address.

I need the ability to be able to click on CheckBox1 and change the choice, and that change impact all addresses associated with that individual.

For example, in the below screenshot 1548 Treeview Court is the 'Active_Address'. If I check the box for 111 Acme Lane that address should become the 'Active_Address' (Yes) and all other addresses with the same CML ID should change to 'No'.

Is this possible?

Phineas_0-1708098885449.png

 

Categories:
  • elseb Profile Picture
    774 Moderator on at

    Hi try this:

     

    OnCheck: Collect(colAddressesSelected, {address:ThisItem.address, ID:ThisItem.ID})

    OnUncheck: RemoveIf(colAddressesSelected, ID=ThisItem.ID)

    Default: If(IsBlank(LookUp(colAddressesSelected, address=ThisItem.address)), false,true)

     

    Of course if you're reading the default state of the checkbox from the database, you will have to add coalesce or if to accommodate for that etc.

     

  • Phineas Profile Picture
    5,331 Moderator on at

    Thank you for your reply.

     

    Yes, it is a Gallery reading and displaying data from a SharePoint list.

     

    The action should be reflected in the appropriate boxes in the app and update same in the SharePoint list.

     

    Please explain how coalesce would look.

  • elseb Profile Picture
    774 Moderator on at

    In this application the coalesce works a bit like if, 

    but actually in your case you probably won't need it.

    What you can do instead is on visible of the screen or app start grab all duplicate addresses into that collection to display checkboxes correctly, now I have an idea for a code but what I have in mind would be quite complicated so lets see if we can do some enabling work instead to make it simple.

     

    how are the addresses added to the records? are you storing new ones in a separate list to prevent mismatches cause by types etc.? I can only assume if everyone is free typing you'd have the same address entered in variety of ways?

  • Phineas Profile Picture
    5,331 Moderator on at

    There are two SP List.

    SPList1 is the Client_List, with basic client information - except the addresses.

    SPList2 is the Address_List, with all of the individual and not for profit addresses. No address appears more than once. One individual or not for profit can have more than one address, however only one address can be the active address.

    I need the functionality we are working on to be able to change all checkboxes if one is changed.

    Example: Joe Schmoe has four addresses in the list, Address1 is active and the checkbox is true/green in the Power App. If I check Joe's Address2 in the Gallery, all the other addresses should remain false and Address1 should turn false.

    Also, if by some chance someone unchecks all of Joe's boxes a notification should pop up stating at least one address must be selected as active. 

  • elseb Profile Picture
    774 Moderator on at

    Excellent explanation and it's all very clear to me now, here's my solution:

     

    somewhere before you display the gallery create a collection:

    ClearCollect(
    colAddressesSelected,
    LookUp(ADDRESS_LIST, ID=SELECTED_CUSTOMER.selected_address_id))

    SELECTED_CUSTOMER.selected_address_id is a column that stores assigned address to that customer

     

    Checkbox default: 

    !IsBlank(LookUp(colAddressesSelected, ID=ThisItem.ID))

    Checkbox oncheck: 

    ClearCollect(colAddressesSelected, AddressGallery.Selected)

    Checkbox onUncheck: 

    RemoveIf(colAddressesSelected, ID=ThisItem.ID);
    If(CountRows(colAddressesSelected)<1, Notify("select at least one address",NotificationType.Error))

     

     

  • Phineas Profile Picture
    5,331 Moderator on at

    Thank you for the detailed reply.

    Let me ask you this first...I've gotten the following formula to update the item selected in the Gallery.

    If I check or uncheck the first item (111 Acme Lane), the box turns green or red accordingly, the test of the box changes to 'Yes' or 'No' accordingly, and the items is updated in the SPList true or false accordingly.

    All I'm missing now is a bit more of code that updates all the other items that have the same CML_ID (the UniqueID). Is this possible?

    Example: If the first item is 'No' (unchecked), and I check it, making it 'Yes', all the above happens - as required, however the other boxes (the other two current shown as 'Yes'), with the same CML_ID don't change to 'No'.

    How do I make this last part happen?

    Current ComboBox 'OnCheck/UnCheck' formula -

    If(ThisItem.Subscriber_Address_1 = Subtitle1_1.Text,
    Patch(Subscriber_Address_List,Maintenance_Address_Summary_Gallery.Selected,
    {Title: Title2_1.Text, Active_Address: Checkbox2.Value}))

    Phineas_0-1708198120861.png

     

  • elseb Profile Picture
    774 Moderator on at

    You're moving in completely different direction now which you haven't mention before.

    You can do it that way (probably not the best to patch splist every time check/uncheck is performed and I think you should consider update button outside of gallery instead.

    You can still do it your way and because you're patching multiple records at once you need to run forall and patch the checkbox status of all the records to your list.

  • Phineas Profile Picture
    5,331 Moderator on at

    My ignorance leaves me lacking in the ability to articulate clearly.

    What I just referenced is what i ended the outcome to be the entire time.

    I can filter my Gallery by 'Name'. If the 'Name' returns several addresses I need the ability to check a box in that item, making it 'Yes/true', and the 'Active' item.

    On that action all other items with the same CML_ID (same person different addresses) would default to 'No'.

    Phineas_0-1708201343970.png

     

  • elseb Profile Picture
    774 Moderator on at

    And this is exactly what I gave you here:  message 6 the content of the gallery is still whatever you want it to be, the only thing required for my code to work is a checkbox with the code added and that collection which will read your list and finds which address is selected as active inside your splist.

    although I assumed your patch will be done after user decides what to click not every time they check/uncheck. But again, you can still do your patch on check uncheck if you really want.

  • Phineas Profile Picture
    5,331 Moderator on at

    Yep, okay. Almost got it.

    I've updated all of my properties as you've recommended. I put my patch in the 'OnSelect' of the checkbox.
    If(ThisItem.Subscriber_Address_1 = Subtitle1_1.Text,
    Patch(Subscriber_Address_List,Maintenance_Address_Summary_Gallery.Selected,
    {Title: Title2_1.Text, Active_Address: Checkbox2.Value}))

    The Patch updates each individually, but I can't get the other to change to the opposite.

    Phineas_0-1708208309936.png


    In the below I manually changed the third item from 'false' to 'true'. The SP List updated the one item to 'true', but didn't change the other two to 'false', even though they show 'false' below, in the SPList (above) they ALL show 'true'.

    Phineas_1-1708208572980.png

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard