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 / Checkboxes with the 'W...
Power Apps
Unanswered

Checkboxes with the 'WITH' function

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All, 

I have a series of checkboxes and one at the top which does Select All. 

The OnCheck on that sets a context var : UpdateContext({AllChecked: true})

The OnUnCheck set the context var : UpdateContext({AllChecked: false})

 

If the user saves the screen (with the checkboxes on) and then goes back into the screen. I want to use the First Record.Column name and if it is Yes.No = Yes then show the tickbox and if it is Yes.No = No then dont show the tickbox. I want the UpdateContexts to overwrite the value (if it is either true or false).

 

I am using an WITH statement on the 'default of each tickbox' 

 

With(
 First(InspectionItemTPHCollection),
 If(
 'PHV Licence' = 'Yes or No'.Yes,
 true,
 AllChecked = true,
 true,
 AllChecked = false,
 false
 
 )
)

This is used so that if it is yes (from the record), show as true, and allchecked as true or false accordingly.

 

It kind of works, but if we do a selectall (uncheck - it doesnt clear all the checkboxes and it brings back what is saved). 

Any idea on how i can craft this WITH command - that is correct ? I am almost there! 

Any help would be amazing. 

 

 

 

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

    Hi @Anonymous ,

    Firstly, With() is setting a (very) temporary variable that you have to name and use in the code. I have a blog on its use in the Delegation context. I do not know the context of what you are doing here, but the syntax structure would be something like this

    With(
     {wRecord: First(InspectionItemTPHCollection)},
     wRecord.'PHV Licence' = 'Yes or No'.Yes || wRecord.AllChecked
    )

    You do not need the If/Yes/No (see this blog of mine)

     

    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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    So I am getting the same issue really... 

    When i save individual rows - works fine 

    When i select all - it ticks all the boxes

    When i de-select all - it keeps the boxes that are saved! 

    We are almost there ! 

    Any other help would be amazing! 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    So, can i give you some more context please - becasue we almost there on this and it would be amazing for your help. 

     

    I need to do a 'save' and i have this by a patch to the collection. I also have a back button which doesnt save - this works great. 

     

    I have a checkbox with OnChecked - context variable : true and OnUnchcked same variable but false. If I need to tweak this then thats fine. 

     

    Your code almost 99% does the job, but when i de-select it doesnt 'de-select' it just shows what was saved already. 

     

    Can you please help a little further please ? I am at a loos end with it and sleepless nights! 

     

  • WarrenBelz Profile Picture
    154,881 Most Valuable Professional on at

    @Anonymous ,

    The code I sent will look at the first record in your collection and if the 'PHV Licence' field is Yes and the AllChecked field is true, it returns true, but now I see that the AllChecked is a Variable, so, you really do not need the With() statement here

    First(InspectionItemTPHCollection).'PHV Licence' = 'Yes or No'.Yes || AllChecked

    I will be offline now due to time zone

     

    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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Ahh still the same thing - it isnt removing the unOnCheck. 

     

    jdhough55_0-1656330730946.png

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Also by default all the checkboxes are true, which they shouldnt be.. Esepcially if it is a new investigation then they should default to false. 

  • WarrenBelz Profile Picture
    154,881 Most Valuable Professional on at

    @Anonymous ,

    You need to reset them - you can make the Reset property a Variable that you set to false, then true.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I have done that but they dont refresh becasue of the formula thats on the checkbox which is : 

     

    First(InspectionItemTPHCollection).'PHV Licence' = 'Yes or No'.Yes || AllChecked

     

    I think this formula needs to change and i really need some help 😞 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    So the AllChecked part is either true or false. So if it is true then we need to show the tick, if it is false then it should be false. So if the record is Yes  and allchecked is false it should be false. 

    If Alleched is true and the record is yes then it should show the tick. This gives a bit more context into this annoying problem. Thankyou very much, 

  • WarrenBelz Profile Picture
    154,881 Most Valuable Professional on at

    @Anonymous ,

    That is correct - your Default property needs to return either true or false - which will show the tick if true or not is false. This code

    First(InspectionItemTPHCollection).'PHV Licence' = 'Yes or No'.Yes || AllChecked

    will show a tick if EITHER

    • The field 'PHV Licence' is Yes OR
    • The variable Allchecked is true

    This is a logic rather than a coding issue - you just need to code it in accordance with when you want it checked.

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 602

#2
WarrenBelz Profile Picture

WarrenBelz 473 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 310

Last 30 days Overall leaderboard