cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
venka91
Super User
Super User

Need help with setting Checkbox Default Value with Validation

Hi there,

 

I have 3 checked boxes in my Screen namely 5:30 AM, OnHome , OnDuty.

All these checkbox default property is already set to show the value from my sharepoint list.  

However, i would like to make sure, when user clicks any other checkbox, the other two checkbox is unchecked. Please assist.

 

As you see below, my checkboxes are in gallery. So i set the Default property of checkbox 5:30 as ThisItem.5:30 AM. So this shows the value whatever exists in the Sharepoint.

 

However, when i check Home/Leave checkbox, i would like to uncheck the 5:30 AM and travel/OD.

Like wise when click on travel/OD, the other two checkboxes must be unchecked.

 

At the same time all 3 boxes, can also be unchecked, which is considered the student is missing from the class.

 

venka91_0-1640066711197.png

 

9 REPLIES 9
AJ_Z
Super User
Super User

the way i did this was first onvisible i did this:

UpdateContext({VarCheckBoxUpdate:""})

AJ_Z_0-1640145590345.png

 

Then I change the default property e.g. for my 5:30 checkbox i did:

If(VarCheckBoxUpdate = "", ThisItem.'5:30 AM',VarCheckBoxUpdate = "5:30",true,false)

then i added an OnUnCheck to each of them:

UpdateContext({VarCheckBoxUpdate:""});Concurrent(Reset('530'),Reset(home),Reset(duty))

AJ_Z_1-1640146247300.png

 

then i added oncheck for each of them:
for the checkbox i called 530 i did:

UpdateContext({VarCheckBoxUpdate:"5:30"});Concurrent(Reset('530'),Reset(home),Reset(duty))

for the checkbox i called home i did:

UpdateContext({VarCheckBoxUpdate:"home"});Concurrent(Reset('530'),Reset(home),Reset(duty))

for the checkbox i called duty i did: 

UpdateContext({VarCheckBoxUpdate:"duty"});Concurrent(Reset('530'),Reset(home),Reset(duty))

 

then i added Default for each of them:
for the checkbox i called 530 i did:

 

If(VarCheckBoxUpdate = "", false,VarCheckBoxUpdate = "5:30",true,false)

 

for the checkbox i called home i did:

 

If(VarCheckBoxUpdate = "", false,VarCheckBoxUpdate = "home",true,false)

 

for the checkbox i called duty i did: 

 

If(VarCheckBoxUpdate = "", false,VarCheckBoxUpdate = "duty",true,false)

 


this means onvisible it allows the sharepoint to come through. when you check one it unchecks the others

 

i named the checkboxes i used 530, home and duty

Please try my suggestion and let me know how it goes. there are many other ways to do this aswell by the way this is just one of them. if this is your solution please click accept as solution.

If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !

But you are adding two statement in one Property Default...

Is this possible ? i tried to do that, but it says errors:

 

Example : very first, you adding the default property of 5:30 checkbox as : 

If(VarCheckBoxUpdate = "", ThisItem.'5:30 AM',VarCheckBoxUpdate = "5:30",true,false)

 

and later you said,

 

then i added Default for each of them:
for the checkbox i called 530 i did:

 

If(VarCheckBoxUpdate = "", false,VarCheckBoxUpdate = "5:30",true,false)

 

. I am confused.

 

Apologies for confusing you i was just showing you how to pull the existing value from sharepoint incase you wanted, But it is probably best if you just use:
If(VarCheckBoxUpdate = "", false,VarCheckBoxUpdate = "5:30",true,false)

in the default.

try this and let me know how it goes

 

If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !

this is because you are updating sharepoint anyways

If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !

Thank you. But if i dont put in default Property of checkbox as ThisItem.530, for the past dates when i view my attendnace, i dont get the values from sharepoint right ?

is this to view as well apologies i though this was just to edit/update them. In that case this is probably best:

Make OnUnCheck for all of them:

UpdateContext({VarCheckBoxUpdate:"X"});Concurrent(Reset('530'),Reset(home),Reset(duty))

 

change Default for each of them:
for the checkbox i called 530 i did:

 

If(VarCheckBoxUpdate = "", ThisItem.'5:30 AM',VarCheckBoxUpdate = "X",false,VarCheckBoxUpdate = "5:30",true,false)

 

for the checkbox i called home i did:

 

If(VarCheckBoxUpdate = "", ThisItem.'Home',VarCheckBoxUpdate = "X", false,VarCheckBoxUpdate = "home",true,false)

 

for the checkbox i called duty i did: 

 

If(VarCheckBoxUpdate = "", ThisItem.Duty,VarCheckBoxUpdate = "X", false,VarCheckBoxUpdate = "duty",true,false)

 

Please correct the columns name for the Defaults I guessed them I put:

ThisItem.'5:30 AM'
ThisItem.Home

ThisItem.Duty

These must be corrected to the real column names from the datasource

If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !

AJ_Z
Super User
Super User

The above change pulls sharepoint unless you change it.

it resets everytime you navigate to the screen due to the OnVisible 🙂 .
If you change the record on the screen e.g. you use a gallery to pick a new row or record to edit you should make sure you reset to variable there aswell 🙂 test this and let me know if it works try it on more than one row

If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !

NelaEdu
Advocate I
Advocate I

@AJ_Z thanks this was exactly the solution I was looking for

Thank you so much for your efforts. However, i am unable to achieve it. When i click on Home, or Duty, the other box is not getting unchecked.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,330)