cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
slalithprasad
Helper I
Helper I

Circular reference Between Checkboxes

Hello, I have checkboxes placed in my gallery and a checkbox outside gallery that allows me to check all the check boxes that are from the gallery.  now, If I uncheck any checkbox in gallery, it means that not all items from the gallery are selected and I want this to be reflected on the checkbox that is placed outside the gallery and uncheck it. 

 

here is the formula I've written, I get circular reference error. How can I work around this - 

 

 Circular reference error.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Alex_10
Super User
Super User

@slalithprasad 

 

// checkbox outside gallery

CheckAll.Default = ctxNoSingleUnchecked

 

CheckAll.OnCheck = 

UpdateContext({ctxAllCheck: false});

UpdateContext({ctxAllCheck: true});
UpdateContext({ctxNoSingleUnchecked: true});
Reset(Gallery1);

 

CheckAll.OnUncheck= 

UpdateContext({ctxAllCheck: true});

UpdateContext({ctxAllCheck: false});
UpdateContext({ctxNoSingleUnchecked: false});
Reset(Gallery1);

 

 

// checkbox inside gallery

CheckBox1.Default = ctxAllCheck

 

CheckBox1.OnCheck=

If(CountRows(Filter(Gallery1.AllItems, !Checkbox1.Value))=0, UpdateContext({ctxNoSingleUnchecked: true}) );

 

CheckBox1.OnUncheck=UpdateContext({ctxNoSingleUnchecked: false})

 

 

 

View solution in original post

3 REPLIES 3
Alex_10
Super User
Super User

@slalithprasad 

 

// checkbox outside gallery

CheckAll.Default = ctxNoSingleUnchecked

 

CheckAll.OnCheck = 

UpdateContext({ctxAllCheck: false});

UpdateContext({ctxAllCheck: true});
UpdateContext({ctxNoSingleUnchecked: true});
Reset(Gallery1);

 

CheckAll.OnUncheck= 

UpdateContext({ctxAllCheck: true});

UpdateContext({ctxAllCheck: false});
UpdateContext({ctxNoSingleUnchecked: false});
Reset(Gallery1);

 

 

// checkbox inside gallery

CheckBox1.Default = ctxAllCheck

 

CheckBox1.OnCheck=

If(CountRows(Filter(Gallery1.AllItems, !Checkbox1.Value))=0, UpdateContext({ctxNoSingleUnchecked: true}) );

 

CheckBox1.OnUncheck=UpdateContext({ctxNoSingleUnchecked: false})

 

 

 

@Alex_10  Thanks, The only thing which I do not understand here is 

CheckAll.OnCheck = 

UpdateContext({ctxAllCheck: false});

UpdateContext({ctxAllCheck: true});

 

CheckAll.OnUncheck= 

UpdateContext({ctxAllCheck: true});

UpdateContext({ctxAllCheck: false});

 

Why are we making it false and then true on check and why are we making it true and then false onuncheck? 

 

I think it also refreshes the ctxAllCheck that is been applied on the items of gallery. 

Alex_10
Super User
Super User

@slalithprasad 

 

this is for the case:

when you check all first and then uncheck any checkbox in the gallery and after want to check all again by pressing checkbox outside.

 

you may test it with the following code to see what happens in the case i described (basically the logic will not work properly):

CheckAll.OnCheck = 

UpdateContext({ctxAllCheck: true});

 

CheckAll.OnUncheck= 

UpdateContext({ctxAllCheck: false});

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,546)