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

Link Office 365 Calendar

I'm building an app so that users in my office can request a "session" for a headshot. They fill out a form that has their name, email, phone number, session desired, and the date/time they would like their session (I used a date/time picker). I have this all routed to a sharepoint list, and when a user submits a form, I set up a workflow to send a "New Approval Request" email to the photographer to reject or approve, which will then send an email to the user who requested the session with the response. All of this works well.

 

I would ideally like to prevent users from booking a time that already has an event. I don't know of a workflow--or built in PowerApps function--that would allow me to signal an error if there was already an event at the time they intended to request. I can't even figure out how to display a calendar so users can at least see the busy times before they choose their own date. I've followed the instructions to use the CalendarGetItems function, but I haven't been able to get PowerApps to recognize the name of my table. The MS Bookings isn't what we're looking for either.

 

tl;dr Does anyone have any ideas to try so I can display a calendar (that lives in "Your Calendars" in Outlook365), or prevent users from picking times that already have events? Is there a CalendarDatePicker that I can use that shows current events?

 

Here is a photo of my app screens (blue square is the date picker):

App.JPG

 

 

This is the set of instructions I get errors with (photos below)

 

error.JPGerror2.JPG

3 REPLIES 3
Leo09
Level 8

Re: Link Office 365 Calendar

You cannot prevent users from booking a time that already has an event, whether you will prevent to modify the calendar of all event, or you will allow them to fill it for all event, I think.

er
Level: Powered On

Re: Link Office 365 Calendar

So I couldn't put the calendar inside the powerapp, but I put the calendar on the Sharepoint page and set up a flow to continue to add new Office365 events.

Anonymous
Not applicable

Re: Link Office 365 Calendar

I know you've found a workaround already, but I like the challenge 🙂


By the looks of it, you're just using sharepoint list and timestamp fields for your app and the Calendar is secondary - so you can do this without the calendar.  If you specifically want the Calendar, assuming you're putting the actual bookings into a Calendar and then pulling them out again, this is also possible - but why bother then with the list?

 

So, using a list and no Calendar:

When pulling a date from Sharepoint, Powerapps presents something that's not quite a datepicker, but actually a datepicker plus two numerical dropdowns which it prepopulates with numbers that reflect Hours and Minutes.  When you hit "Update" it strings the dropdowns together to create a datetime value.

 

 

Assuming your list has a "StartTime" column and an "EndTime" Column made of datetime values and you're using an EditForm on your screen with the defaulty date pickers named "DateValue1" for the first, "HourValue1" for the second dropdown and "MinuteValue1" for the last dropdown of the StartTime datepicker - then:

 

 

Include a gallery on the screen and set it's Items property to;

 

Filter('MySharePointList', DateDiff(StartTime,DateValue1.SelectedDate,Days)=0)

This should populate the gallery with any items in the list that are on the same day/date as what the user has selected in the first datepicker dropdown named "DateValue1".

 

 

You can then set the onChange property of EACH of the StartTime datepicker controls to the following;

 

 

UpdateContext({varStartTime: DateValue1.SelectedDate + Time(Value(HourValue1.Selected.Value), Value(MinuteValue1.Selected.Value), 0)});
Clear(collectClash);
ForAll(MyGallery.AllItems,If(StartTime=varStartTime, Collect(collectClash, {Clash: true}),Collect(collectClash, {Clash: false})));
UpdateContext({varClash: If(CountRows(Filter(collectClash, Clash=true))=0,false, true)})

 

 

 

When you change any of the pickers, it will then put all three together to create a datetime variable called varStartTime and check this against all the datetimes in your gallery - for each of the checks it will update a collection (unfortunately we can't update a variable inside a ForAll yet) and then when it's done creating the collection, if any of the checks returned 'true' (which should in theory onle be one) it will then set a variable called varClash to 'true'.  

You can then create a dialogue box with a message saying "Sorry you've got a clash" and a button saying "OK".

 

Set the OnSelect property of the button to;

 

Clear(collectClash);
UpdateContext({varClash: false})

 Then set the visibility of both the message and the button to varClash.

 So when the varClash variable is updated to true, the dialogue pops up, and when you click "OK" it clears the checks and sets the varClash variable back to false, which makes your dialogue disappear.


You can use this to build more logic, like resetting the counters or preventing an update whenever there is a clash.

 

For O365 Calendar items there are a few posts about this - this is one;
https://powerusers.microsoft.com/t5/PowerApps-Forum/Office-365-Calendar-events-won-t-show/td-p/4025

 

There are many ways to skin this particular cat using Calendar, but for the purposes of answering the original question - hope this helps!

 

R

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,019)