cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Vinith46
Level: Powered On

powerapps to check with startdate and enddate against sharepoint

Hi , Could you help me to resolve .

 

i am creating an app for for the technicians(Each technician has an unique ID), Users will book for technicians and technician will be alloted for that work  with start and end date booked.

now when an new user try to book for same technician(ID) then he should not be allowed to book for same startdate and enddate as he is already occupied with work. so here i have to compare with sharepoint for that Id weather he is already booked for that time period based on startdate and enddate.

In App i have startdate and enddate and data is getting saved in sharepoint with startdate and enddate.

 

Could you please help me for this, i have tried multiple codes but unable to find correct solution.

i have tried below code but its not correct, Its nly searching for one condition, we need to search for between dates and avaliable dates aswell

Filter(
'Listname',
startDateColumn >= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate /* <-- DateColumn is a Date Time type column in sharepoint list. DatePicker1 represents the Start Time, DatePicker2 represents the End Time */
)

 

4 REPLIES 4
Super User
Super User

Re: powerapps to check with startdate and enddate against sharepoint

Hi @Vinith46 

 

To get the list of Technicians, that are available between the two dates, you can use the below expression:
Filter(
    TechnicianDetails,
    !(
        And(StartDate >= DatePicker1.SelectedDate,StartDate <=DatePicker2.SelectedDate) 
        || 
        And(EndDate>= DatePicker1.SelectedDate,EndDate <=DatePicker2.SelectedDate)
    )
) 
Here, TechnicianDetails is my SP list with StartDate and EndDate as columns. While, DatePicker1 holds the filter startdate and DatePicker2 is for the Enddate.MicrosoftTeams-image (128).png

 

Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
svijay_001
Level: Powered On

Re: powerapps to check with startdate and enddate against sharepoint

Hello @Vinith46 

 

From your description, I understand that you would like prevent booking of a technicians on an already booked date - Meaning there should be no no existing work on the dates you are planning to book. 

 

Well there should be 3 conditions met if we take a specific Technician. 

 

  1.  The current booking start date should not be between any of the previously booked Start &  End dates (Previous Bookings).
  2.  The Current booking end date  should not be between any of the previously booked Start &  End dates (Previous Bookings).
  3. The bookings whose  start date is less than the current booking start date should not have the lesser end date than that of the current booking's end  date.

 

To sum up the above condition :

=====================

CB --> Current Bookings

PBs --> Previous Bookings

 

There will be overlap of work a specific work if  there are bookings returned in below Pseudocode conditions : 

 

CB.StartDate  between AnyOf(PBs.StartDate) && not between AnyOf(PBs.EndDate)

CB.EndDate  between AnyOf(PBs.StartDate) && not between AnyOf(PBs.EndDate)

CB.StartDate  greater than AnyOf(PBs.StartDate)  | for that PB | CB.Enddate > PB.Enddate

 

Sample Snippet of the Filter query Power Apps: 

Filter('Technician Booking List',Technicians.Selected.id= Title && (Dtpicker_Startdate.SelectedDate <= End Date' && Dtpicker_Startdate.SelectedDate>= 'Start Date' || Dtpicker_Enddate.SelectedDate >='Start Date' && Dtpicker_Enddate.SelectedDate <= 'End Date' || Dtpicker_Startdate.SelectedDate <= 'Start Date' && Dtpicker_Enddate.SelectedDate >= 'End Date'))

 

If the above filter returns any item - then the booking should not be allowed to avoid the overlapping.

 

Fresh Booking :

==========

There is nothing being populated under the "Already Booked days"
001 - Copy.png

 

Now when we try to book something over lapping :

 

002 - Copy.png

 

 

The Gallery source for the "Already Booked Dates"003 - Copy.png

 

Book Button DisplayMode source: 

 

004 - Copy.png

 

Hope this helps ! 

svijay_001
Level: Powered On

Re: powerapps to check with startdate and enddate against sharepoint

Hello @Vinith46 

From your description, I understand that you would like prevent booking of the technicians on an already booked date - Meaning there should be no no existing work on the dates you are planning to book. 

 

Well there should be 3 conditions met if we take a specific Technician. 

 

  1.  The current booking start date should not be between any of the previously booked Start &  End dates (Previous Bookings).
  2.  The Current booking end date  should not be between any of the previously booked Start &  End dates (Previous Bookings).
  3. The bookings whose  start date is less than the current booking start date should not have the lesser end date than that of the current booking's end  date.

 

Filter Snippet for the to return the items (if met the converse of the above condition from the previous bookings) : 

Filter('Test List',Technician_id.Selected.Title= Title && (Dtpicker_Startdate.SelectedDate <= 'End Date' && Dtpicker_Startdate.SelectedDate>= 'Start Date' || Dtpicker_Enddate.SelectedDate >='Start Date' && Dtpicker_Enddate.SelectedDate <= 'End Date' || Dtpicker_Startdate.SelectedDate <= 'Start Date' && Dtpicker_Enddate.SelectedDate >= 'End Date'))

If items are returned. then the booking should not be fulfilled

===========

[Screenshots]

===========

Fresh Booking

001 - Copy.png

 

When there is already existing Booking

 

002 - Copy.png

 

Already Booked days Gallery Source

003 - Copy.png

 

Book Button source :

004 - Copy.png

Community Support Team
Community Support Team

Re: powerapps to check with startdate and enddate against sharepoint

Hi @Vinith46 ,

Do you want to prevent users from booking for same technician(ID) with same startdate and enddate?

 

Th user @Mays has faced same issue with you, please check my response within the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/How-to-make-powerapps-prevent-user-from-reque...

 

On your side, please take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

If(
   !IsBlank(LookUp('Listname', startDateColumn <= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate)),
Notify("The days from " & startDatePicker1.SelectedDate & " to " & LookUp('Listname', startDateColumn <= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate).endDateColumn & " has been booked for current  technician!", NotificationType.Error),
!IsBlank(LookUp('Listname', startDateColumn >= startDatePicker1.SelectedDate && endDateColumn >= endDatePicker2.SelectedDate)),
Notify("The days from " & LookUp('Listname', startDateColumn <= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate).startDateColumn & " to " & endDatePicker2.SelectedDate & " has been booked for current  technician!", NotificationType.Error),
!IsBlank(LookUp('Listname', startDateColumn >= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate)),
Notify("The days from " & LookUp('Listname', startDateColumn <= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate).startDateColumn & " to " & LookUp('Listname', startDateColumn <= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate).endDateColumn & " has been booked for current  technician!", NotificationType.Error),
SubmitForm(EditForm1) /* <-- Submit your form data */ )

 

In addition, if you also want to search for the specific technician in your SP list, please consider modify above formula as below:

If(
   !IsBlank(LookUp('Listname', startDateColumn <= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate && TechnicianIDColumn = "Specific Technician ID")),
Notify("The days from " & startDatePicker1.SelectedDate & " to " & LookUp('Listname', startDateColumn <= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate).endDateColumn & " has been booked for current  technician!", NotificationType.Error),
!IsBlank(LookUp('Listname', startDateColumn >= startDatePicker1.SelectedDate && endDateColumn >= endDatePicker2.SelectedDate && TechnicianIDColumn = "Specific Technician ID")),
Notify("The days from " & LookUp('Listname', startDateColumn <= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate).startDateColumn & " to " & endDatePicker2.SelectedDate & " has been booked for current  technician!", NotificationType.Error),
!IsBlank(LookUp('Listname', startDateColumn >= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate && TechnicianIDColumn = "Specific Technician ID")),
Notify("The days from " & LookUp('Listname', startDateColumn <= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate).startDateColumn & " to " & LookUp('Listname', startDateColumn <= startDatePicker1.SelectedDate && endDateColumn <= endDatePicker2.SelectedDate).endDateColumn & " has been booked for current  technician!", NotificationType.Error),
SubmitForm(EditForm1) /* <-- Submit your form data */ )

 

Please consider take a try with above solution, then check if the issue is solved.

 

More details about the Filter functions and IsBlank function, please check the following article;

Filter functions

IsBlank function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 513 members 4,537 guests
Please welcome our newest community members: