cancel
Showing results for 
Search instead for 
Did you mean: 

Get SharePoint Calendar Events and Post to Teams

Hello Flow Fans!

 

Today I wanted to write about a solution I recently wrote which ties together Flow, SharePoint and Teams.  I wanted to utilize a recurring Flow, set to run every day to grab the current days events from a SharePoint calendar and post a message to my Teams channel to let everyone know what events are occuring today.  Pretty cool right?  Let's take a look at how to set this up.

 

1.  Create a blank Flow and add a Recurrance Trigger.  Configure the advanced settings so that the Flow runs every day at 8 per the screenshot below:

Screen Shot 2018-09-10 at 9.36.13 AM.png

 

 

2.  Add a Get Items - SharePoint Action.  Point this to the URL where you SharePoint calendar is stored. 

Note:  SharePoint Calendars will NOT show in the dropdown of list options.  You have to click the "Manual" option and type in the name of your SharePoint Calendar

 

3.  Now we need to configure the Filter options for the Get Items so that it will get only the current day's items.  This step is a little tricky. We can't do a simple EventDate eq 'utcNow()' because the EventDate is a Date Time so that evaluation will only work if the exact date and time matches.  Additionally, we can't use a formateDate on the EventDate field either.  That leaves us with using greater than and less than expressions to check if the event is between the 12am and 11:59pm on the current date as shown below:

 

EventDate ge 'utcNow('yyyy-MM-ddT00:00:00Z')' and EventDate lt 'addDays(utcNow(),1,'yyyy-MM-ddT00:00:00Z')' 

 

Screen Shot 2018-09-10 at 9.37.13 AM.png

 

4.  We need to get these results in a user-friendly format to post to Teams.  To do this, we will insert a "Data Operations - Select" action.  Pass in the Values from our Get Items action and fill out the item value pairs for whatever information you want to show as shown in the screenshot below:

Screen Shot 2018-09-10 at 9.47.42 AM.png

 

 

5.  Next, we'll insert a "Data Operations - HTML" action so that we can format our output into an easy to read HTML table layout

Screen Shot 2018-09-10 at 9.47.46 AM.png

 

 

 

 

6.  Finally, add a Teams - Post to Channel action.  Point this to your Team and Channel and set the value to your HTML Output

Screen Shot 2018-09-10 at 9.47.47 AM.png

 

 

 

You can use this same method to send a daily email of the current day's events as well.  Hope this was helpful!

Comments

Great stuff!

I am doing this today.

But how would you modify your formula if you wanted the flow to only run once per week and include the whole weeks events in the post on teams?

 

So for example UtcNow +5 days for example.

Flow is triggered every monday at 8 in the morning.

Export all events from monday (the day the flow runs) and then 5 days ahead.

 

That should be pretty easy to do.  If you set the Flow to run once a week at the start of the week then the only thing you'd need to change in the directions is the Recurrance settings and the filter in the Get items.  If you change the "Less Than" function to this:  

 

addDays(utcNow(),5,'yyyy-MM-ddT00:00:00Z')

That should be the events from the start of the week plus 5 (typical work week).

 

Well i got it to work in a way.

 

First error however is that the table that is created mixes the events. So i get one event that is today in the middle of the list and one event that is in two days at the top of the list.

Screenshot: http://prntscr.com/ku3v1j

 

Second error i found is that the times in the post is all wrong.

If you view the screenshot above and see the first start time in the top of the list.

It says 12.30.00

But in the calendar that event is scheduled for 14,30.00

So it seems everything is off by two hous

 

 

Nice job, another alternative would be to use a rich card to post to Teams, which can then be more interactive. 

 

https://medium.com/@smcollier/using-flow-to-post-todays-events-from-sharepoint-to-teams-964f5fd2407c...

Meet Our Blog Authors
  • Co-founder of https://plumsail.com, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • Solution Architect with Slalom, and organizer of the Boston Office 365 User Group, and long term SharePoint/Office 365 veteren. Find more at http://www.davidlozzi.com. Follow @DavidLozzi
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc ( https://triad.co.uk)
>