cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

How to detect if a SharePoint calendar event exists at a specific date and time

Hi. 

The short:

Is there a way to detect if an event exists in a SharePoint calendar with a specific date and start time?  For example, does an event exist on _dateSelected with a start time of 9:35?

 

The long:

I am building a booking app for a set of iPads in a school situation.  They are always booked for specific time slots, so the intent is for the user to book a slot without having to fill out forms.  For example, in the screen shot below, clicking on the period 4 (P4) button will take the user to a confirmation screen, which, upon confirmation, automatically creates an event in the SharePoint calendar for the selected date and the period 4 timeslot.  This is all working as it should.

booking-screen.jpg

What I would like to do is change the colour and functionality of the buttons depending on whether or not a booking already exists for that period.  E.g. make the buttons red if a booking already exists, and direct the user to either the booking confirmation page or the existing booking details page as the case may be.

 

This all hinges on detecting whether an event exists in the calendar for that specific date and time.  I have spent many hours on tutorials, forums and videos, but can't figure it out.  I am a rank beginner with PowerApps, trying to learn by bumbling my way through.  Any thoughts are much appreciated.

 

Chris

 

1 ACCEPTED SOLUTION

Accepted Solutions
Regular Visitor

Thanks, cds.  I spent a lot of time trying to understand your formula and eventually came up with a solution.  The calendar on the main screen, created automatically when the app was created from the SharePoint Calendar, is apparently not a Date Picker control, but I get where you are going with this and learned about the date picker control in the process.  On trying to understand the filter part of the formula better, I came across the Lookup function, which proved to be useful.

 

When an event is created in my app, the event title is automatically set to "Booked Period X", where X is the period number.  The date selected on the calendar view is stored in a variable called _dateSelected.  My solution is:

 

If(LookUp(SharePointCalendarName, DateValue(Text(StartTimeColumnName)) = _dateSelected && ThisRecord.TitleColumnName="Booked Period X", true), red, green)

 

This works.  I realize that Lookup only returns the first matching value and is not delegable, but there should only be one matching event in my use case, and past events can be occasionally deleted to prevent delegation issues.

 

Although I didn't use your solution as-is, it led me in a direction that proved worthwhile.  Thank you for your assistance.

Chris

View solution in original post

4 REPLIES 4
Highlighted
Impactful Individual
Impactful Individual

just add something like this 

 

If(DatePicker.SelectedDate.Value exactin Filter(Datasource, Room = RoomDropdown.value).Starttime), Red, Black)

Highlighted
Impactful Individual
Impactful Individual

apply it to onselect of the button as well and could Notify("Sorry this time is already booked", NotificationType.Information, 2000)

Regular Visitor

Thanks, cds.  I spent a lot of time trying to understand your formula and eventually came up with a solution.  The calendar on the main screen, created automatically when the app was created from the SharePoint Calendar, is apparently not a Date Picker control, but I get where you are going with this and learned about the date picker control in the process.  On trying to understand the filter part of the formula better, I came across the Lookup function, which proved to be useful.

 

When an event is created in my app, the event title is automatically set to "Booked Period X", where X is the period number.  The date selected on the calendar view is stored in a variable called _dateSelected.  My solution is:

 

If(LookUp(SharePointCalendarName, DateValue(Text(StartTimeColumnName)) = _dateSelected && ThisRecord.TitleColumnName="Booked Period X", true), red, green)

 

This works.  I realize that Lookup only returns the first matching value and is not delegable, but there should only be one matching event in my use case, and past events can be occasionally deleted to prevent delegation issues.

 

Although I didn't use your solution as-is, it led me in a direction that proved worthwhile.  Thank you for your assistance.

Chris

View solution in original post

Highlighted
Impactful Individual
Impactful Individual

I'd say that is a bigger win than just getting a copy-paste solution 👍😃

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (5,219)