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

Disable checkbox by using datepicker From and To

Hi, 

I am looking for help with a deskpicker app. Currently have a scenario where all employees can book a desk, but we don't want to have it booked when someone already picked it up, so the date when it was booked up and between dates where the user set Start and From should be disabled until he changes to that dates where it is available.

 

Explanation:

Have two datepickers where the employee can define when they want to have it booked:

1. Start (for date From)

2. End (for dates To)

and Multi-Checkboxes named like this:

3. Desk 1, Desk 2, Desk 3 etc

 

Code:

1. Start has a default schema, DefaultDay is Today(), I changed only DateTimeFormat to LongDate

2. End has the same as Start

3. Desk 1 is named a CheckBox1

OnCheck is resetting other checkboxes which means the only one CheckBox can be checked, if you check another it will be unchecked plus it is changing the color, also is creating MyVar with a Desk number to patch it to the Sharepoint:

 

 

UpdateContext({MyVar:"Desk 1"});
UpdateContext({varPressed:RGBA(100, 100, 0, 1)});
Reset(Checkbox2); Reset(Checkbox3); Reset(Checkbox4); Reset(Checkbox5)

 

 

Next one:

DisplayMode, the code is working fine when the date is picked so, for example, the user picked 5 July as the Start Date and End date but when he tries to pick between 4 July and 6 July the desk is available, the code what I have is :

 

 

If(Checkbox1.Text in Collection.DeskName && Start.SelectedDate in Collection.StartDate && EndSelectedDate in Collection.EndDate, DisplayMode.Disabled)

 

 

Setting it up as Gallery probably will fix the issue, but it is not possible in the way I have it, therefore looking at a displaymode.disabled when the date will be picked between. 

 

Where is available but 5th of July is booked by someone

SevenWishes_0-1655899792316.png

Where is disabled as the date 5th is already booked by someone else:

SevenWishes_2-1655899937341.png

 

Any ideas on how this can be sorted as I am struggling on it for a while without finding the solution.

 

EDIT

The idea that could be helpful which I do not know how to do this would be,  a list of all picked-up dates in one label text 

so if you pick 4th July to 8th July, the label will show you after comma 04 July, 05 July, 06 July, 07 July until it reaches the 8th of July. But no idea how to do this. as the code I am using always checking when the Start Date or End date has the same date and if it is it is disabling the desk.

1 ACCEPTED SOLUTION

Accepted Solutions
SevenWishes
Helper I
Helper I

Hi,

I sorted this by myself.

I created a SharePoint list categorized into a few categories, as I wanted to have 6 desks in one list I added 6 desks to one category, another 6 to the next one, etc. After that, I copied it 6 times and only changed the items in everyone.

 

I set up a variable to clear them up: ClearSelect and added it to the Default section of gallery and to the main screen to clear it every time I click on it or open this page

UpdateContext({ClearSelect: Gallery.Selected}); UpdateContext({ClearSelect: {}});

I had to create every ClearSelect for every gallery I created. If there were 5 galleries you had to put up to ClearSelect5:

UpdateContext({ClearSelect5: Gallery5.Selected}); UpdateContext({ClearSelect5: {}});

I added a text label to a checkbox to every gallery, imagine you are adding it to Gallery 1, if you will add it to Gallery 2 need to remove ClearSelect2 from it:

UpdateContext({ClearSelect2: Gallery2.Selected}); UpdateContext({ClearSelect2: {}});
UpdateContext({ClearSelect3: Gallery3.Selected}); UpdateContext({ClearSelect3: {}});
UpdateContext({ClearSelect4: Gallery4.Selected}); UpdateContext({ClearSelect4: {}});
UpdateContext({ClearSelect5: Gallery5.Selected}); UpdateContext({ClearSelect5: {}});

 and visible:

!ThisItem.IsSelected || !Checkbox3_1.Value

 I still do not understand how to define the dates, I did not receive the answers to this thread I will close this one and create another with the link to it where I try to describe the issue.

View solution in original post

1 REPLY 1
SevenWishes
Helper I
Helper I

Hi,

I sorted this by myself.

I created a SharePoint list categorized into a few categories, as I wanted to have 6 desks in one list I added 6 desks to one category, another 6 to the next one, etc. After that, I copied it 6 times and only changed the items in everyone.

 

I set up a variable to clear them up: ClearSelect and added it to the Default section of gallery and to the main screen to clear it every time I click on it or open this page

UpdateContext({ClearSelect: Gallery.Selected}); UpdateContext({ClearSelect: {}});

I had to create every ClearSelect for every gallery I created. If there were 5 galleries you had to put up to ClearSelect5:

UpdateContext({ClearSelect5: Gallery5.Selected}); UpdateContext({ClearSelect5: {}});

I added a text label to a checkbox to every gallery, imagine you are adding it to Gallery 1, if you will add it to Gallery 2 need to remove ClearSelect2 from it:

UpdateContext({ClearSelect2: Gallery2.Selected}); UpdateContext({ClearSelect2: {}});
UpdateContext({ClearSelect3: Gallery3.Selected}); UpdateContext({ClearSelect3: {}});
UpdateContext({ClearSelect4: Gallery4.Selected}); UpdateContext({ClearSelect4: {}});
UpdateContext({ClearSelect5: Gallery5.Selected}); UpdateContext({ClearSelect5: {}});

 and visible:

!ThisItem.IsSelected || !Checkbox3_1.Value

 I still do not understand how to define the dates, I did not receive the answers to this thread I will close this one and create another with the link to it where I try to describe the issue.

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,108)