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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Form Control - Resourc...
Power Apps
Answered

Form Control - Resource availability verfication

(0) ShareShare
ReportReport
Posted on by 7

Dear Power Apps Community,

 

I have this basic form control connected to SP list to book a pool car.

 

RaoNunepalli_0-1684232895229.png

I want to verify my source SP list column availability: if, for the selected Number Plate and Start Date Time & End Date Time also within the time range, a booking exists, notify the user that the booking already exists else submit the form.

Reserve button onSelect property:

If(
Not(
IsBlank(
LookUp(
'SID Pool Car Reservation',
'Availability '.Value = "Free" And 'Number Plate'.Value = DataCardValue10.Selected.Value And 'Start Date' = DateValue1.SelectedDate + Time(
Value(HourValue1.Selected.Value),
Value(MinuteValue1.Selected.Value),
0
) And 'End Date' <= DateValue2.SelectedDate + Time(
Value(HourValue2.Selected.Value),
Value(MinuteValue2.Selected.Value),
0
)
)
)
),
SubmitForm(EditForm2),
Not(
IsBlank(
LookUp(
'SID Pool Car Reservation',
'Availability '.Value = "Booked" And 'Number Plate'.Value = DataCardValue10.Selected.Value And 'Start Date' = DateValue1.SelectedDate + Time(
Value(HourValue1.Selected.Value),
Value(MinuteValue1.Selected.Value),
0
) And 'End Date' > DateValue1.SelectedDate + Time(
Value(HourValue1.Selected.Value),
Value(MinuteValue1.Selected.Value),
0
) And 'End Date' <= DateValue2.SelectedDate + Time(
Value(HourValue2.Selected.Value),
Value(MinuteValue2.Selected.Value),
0
)
)
)
),
Notify("A reservation already exists for the selected pool car and for the selected dates."),
SubmitForm(EditForm2)
)

 

This formula is not working as expected, could you help me where am I doing wrong?

 

Thanks. 

 

Categories:
  • WarrenBelz Profile Picture
    156,526 Most Valuable Professional on at

    Hi @RaoNunepalli ,

    It seems a bit superfluous to even test for the "Free" as you are going to submit if it is not booked, however try this in line with your current logic

    With(
     {
     wStart:
     DateValue1.SelectedDate + 
     Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     ),
     wEnd:
     DateValue2.SelectedDate + 
     Time(
     Value(HourValue2.Selected.Value),
     Value(MinuteValue2.Selected.Value),
     0
     )
     },
     With(
     {
     wBookings:
     Filter(
     'SID Pool Car Reservation',
     'Number Plate'.Value = DataCardValue10.Selected.Value &&
     'Start Date' >= wStart &&
     'End Date' <= wEnd
     )
     },
     If(
     !IsBlank(
     LookUp(
     wBookings,
     Availability '.Value = "Free"
     ).ID
     ),
     SubmitForm(EditForm2),
     !IsBlank(
     LookUp(
     wBookings,
     Availability '.Value = "Booked"
     ).ID
     ),
     Notify(
     "A reservation already exists for the selected pool car and for the selected dates."
     ),
     SubmitForm(EditForm2)
     )
     )
    )

     

    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

  • RN-06021042-0 Profile Picture
    7 on at

    Dear @WarrenBelz ,

    Thank you for your solution.

    The formula is still allowing to make a reservation within the time period of the booking.

    Example: There is already a booking for

    Number Plate: S-ST884 (Stuttgart)

    Start Date: 15/05/2023 08:00

    End Date: 16/05/2023 17:00

    RaoNunepalli_0-1684240860598.pngRaoNunepalli_1-1684240944931.png

     

    But the formula is allowing to make a reservation for the same Number plate, for the same dates from 08:00 to 13:00 or from 08:00 to 16:00. Which is not correct.

    Could you please help to identify the duplicates within the time range as well?  

  • Verified answer
    WarrenBelz Profile Picture
    156,526 Most Valuable Professional on at

    @RaoNunepalli ,

    I suspected you have intermediate timeslots when I responded to this, so this is far more complex than the model you posted - you need to allow for either date (start or end) to be in the period as well as a booking starting before and ending after the period.

    With(
     {
     wStart:
     DateValue1.SelectedDate + 
     Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     ),
     wEnd:
     DateValue2.SelectedDate + 
     Time(
     Value(HourValue2.Selected.Value),
     Value(MinuteValue2.Selected.Value),
     0
     )
     },
     With(
     {
     wBookings:
     Filter(
     'SID Pool Car Reservation',
     'Number Plate'.Value = DataCardValue10.Selected.Value &&
     (
     ('Start Date' >= wStart && 'Start Date' <= wEnd) ||
    			 ('End Date' >= wStart && 'End Date' <= wEnd) ||
     ('Start Date' <= wStart && 'End Date' >= wEnd)
     )
     )
     },
     If(
     !IsBlank(
     LookUp(
     wBookings,
     Availability '.Value = "Free"
     ).ID
     ),
     SubmitForm(EditForm2),
     !IsBlank(
     LookUp(
     wBookings,
     Availability '.Value = "Booked"
     ).ID
     ),
     Notify(
     "A reservation already exists for the selected pool car and for the selected dates."
     ),
     SubmitForm(EditForm2)
     )
     )
    )

     

    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

  • RN-06021042-0 Profile Picture
    7 on at

    @WarrenBelz : Thank you🙂, it works!

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard