web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Dont submit the Form i...
Power Apps
Answered

Dont submit the Form if Time slot is already reserved.

(0) ShareShare
ReportReport
Posted on by 115

Hey.

I have a form. In that I am selecting a particular individual. Then I have 2 date pickers. StartTime and EndTime.

If the person is already booked for that hour. Then dont submit the form.

 

For example. The person is booked for 21st June from 1pm -3pm. And if for the same person another booking is made for 21st june from 2pm-3pm. On the submission of the form it should not submit and show a notification error. 

The start time and end time in the form are date pickers. That is DateValue1, HourValue1 and MinuteValue1.

 

My current submit button looks like this:

If(
CountRows(
Filter(
RList,
DataCardValue14.Selected.'Name (FirstName)' = SA.Value &&
DateAdd(
DateValue1.SelectedDate,
Time(HourValue1.Selected.Value, MinuteValue1.Selected.Value, 0)
) >= ReservationStartTime &&
DateAdd(
DateValue1.SelectedDate,
Time(HourValue1.Selected.Value, MinuteValue1.Selected.Value, 0)
) < ReservationEndTime
)
) = 0,
SubmitForm(Form2),
Notify("The selected member already has a booking during the selected time slot.", NotificationType.Error)
)

 

Above SA is a lookup column where I am match the name.

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,075 Most Valuable Professional on at

    Hi @Unknown123 ,

    I have only focussed on the dates here and assume you have two date pickers (start and end) and have assumed the names on the second one. You need to allow for the possibilities of your period have the start or end on the booked period as well as spanning the booked period.

    With(
     {
     wStart:
     DateValue1.SelectedDate +
     Time(
     HourValue1.Selected.Value, 
     MinuteValue1.Selected.Value, 
     0
     ),
     wEnd:
     DateValue2.SelectedDate +
     Time(
     HourValue2.Selected.Value, 
     MinuteValue2.Selected.Value, 
     0
     )
     },
     If(
     !IsBlank(
     LookUp(
     RList,
     DataCardValue14.Selected.'Name (FirstName)' = SA.Value &&
     (
     (
     ReservationStartTime < wStart && 
     ReservationEndTime > wStart
     ) ||
     (
     ReservationStartTime < wEnd && 
     ReservationEndTime > wEnd
     ) ||
     (
     ReservationStartTime > wStart && 
     ReservationEndTime < wEnd
     )
     )
     )
     ),
     SubmitForm(Form2),
     Notify(
     "The selected member already has a booking during the selected time slot.", 
     NotificationType.Error)
     )
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Unknown123 Profile Picture
    115 on at

    @WarrenBelz 

     

    Thanks for the wonderful expression.

    What do you exactly by this:

    I have only focussed on the dates here and assume you have two date pickers (start and end) and have assumed the names on the second one. You need to allow for the possibilities of your period have the start or end on the booked period as well as spanning the booked period.

    And the above expression is not submitting any data whether the time is same or not.

  • WarrenBelz Profile Picture
    153,075 Most Valuable Professional on at

    Hi @Unknown123 ,

    Assuming you wrote the code you posted, I was simply expanding to what I believed you need  - two date pickers to achieve your comparison and then run the three queries to see if anything in that period overlapped the stored start and end date periods in your data source.

  • Unknown123 Profile Picture
    115 on at

    Thanks it worked.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard