cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

how to limit to selection of check boxes max to 3?

Hello Everyone,

 

Do any one know how can below scenario be achieved. 

 

I have a  screen with 19 checkboxes. Based up on the selection it will update the column in SharePoint list. This part is working as I Expected. 

But the issue is that users can select all the checkboxes and I am not able to limit it to any 3 or max 3 only. 

Any help on this one please?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Advocate I
Advocate I

Re: how to limit to selection of check boxes max to 3?


@rajkumar88 wrote:

@DustinCooper @Pstork1 

 

Here you go. 

 

1. on App start : Set(Checkboxes,0)

2. for each checkboxes oncheck property: Set(Checkboxes,Checkboxes+1)

3.for each checkboxes UNcheck property: Set(Checkboxes,Checkboxes-1)

4.  on a text label → visible property →If(Checkboxes > 3,true,false)

5. on "Save" button →DisplayMode →If(Checkboxes> 3,DisplayMode.Disabled,DisplayMode.Edit)

 

FYI → I have "4 checkboxes" created for this scenario. 


Remove the DisplayMode. as I have shown above, and it should disable the button. 

View solution in original post

18 REPLIES 18
Highlighted
Advocate I
Advocate I

Re: how to limit to selection of check boxes max to 3?

In the OnChange event for each CheckBox add a number variable that adds 1 if the value is true, and subtracts one if its changed to false. Then set the display mode on each to Edit if the variable < 3 and disabled if not. 

 

Edit: Just to clarify each checkbox would use the same variable. 

 

Dustin 

Highlighted
Post Patron
Post Patron

Re: how to limit to selection of check boxes max to 3?

@DustinCooper 

 

I am sorry to asl you again. I am bit new to this and not sure where and how to add exactly. can you please elaborate steps if possible with example? Sorry to bother you. 

Highlighted
Dual Super User II
Dual Super User II

Re: how to limit to selection of check boxes max to 3?

The option I was thinking of was to do the same thing for each checkbox, but then disable/enable the Submit button depending on whether the value of the resulting variable was <3.  That way they can still access the checkboxes to change their selections, but can only submit if they select 3 or less.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Post Patron
Post Patron

Re: how to limit to selection of check boxes max to 3?

@Pstork1 

can we also say that please select only 3 as a small pop-up or hide.unhide text box along with submit button? 

 

and can you please let me know where and how to add code on these checkboxes? 

Highlighted
Advocate I
Advocate I

Re: how to limit to selection of check boxes max to 3?

ChkBx1.pngChkBx2.png

Highlighted
Post Patron
Post Patron

Re: how to limit to selection of check boxes max to 3?

@DustinCooper  thanks a lot dustin. Let me quickly test it and get abck to you. 

 

Highlighted
Dual Super User II
Dual Super User II

Re: how to limit to selection of check boxes max to 3?

In the OnStart for the app use this code

Set(checkedBoxes,0)

For each Checkbox put the following code in the OnChecked property

Set(checkedBoxes,checkedBoxes+1)

And this goes in the OnUnChecked property

Set(checkedBoxes,checkedBoxes-1)

Then put this in the Visible property of the error label

If(checkedBoxes > 3,true,false)

And this in the Display Mode property for the button

If(checkedBoxes > 3,DisplayMode.Disabled,DisplayMode.Edit)

That should be all you need.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Post Patron
Post Patron

Re: how to limit to selection of check boxes max to 3?

hi @DustinCooper ,

 

you solution is disabling other checkboxes after 3 selections and there is no other way to uncheck and check other checboxes. From user prespective they will be confused why remaining are disabled and not allowing them to re-check other checboxes. Do we need to click on reset to select new 3checkboxes? 

Highlighted
Advocate I
Advocate I

Re: how to limit to selection of check boxes max to 3?

For DisplayMode try this: If(Or(CheckBox1.value,sCount<3),DisplayMode.Edit,Disabled)

 

The above should allow the three that are checked to be unchecked (Edit).

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,246)