How to Get a List of Events for a Week from a Calendar in Power Automate

Do you need to retrieve events from a calendar for a given week in your flow?

Getting events from your personal calendars is an easy task in Power Automate using the Outlook connector. However, getting events from a group calendar can be a bit more tricky.

The Get events action from the Office 365 Outlook connector can be used to retrieve all the events on your calendar for the next week, or any period you define. You can also filter the events based on certain criteria, such as the organizer or subject, to further refine your results.

This is also possible for group calendar events, but for this you will need to use the Send an HTTP request action in the Office 365 Groups connector.

This post will explore both methods required for getting a week of events for either a personal or group calendar.

Get Personal or Group Calendar ID

To get a list of events on a calendar you will need to start by getting the calendar ID.

The calendar ID is a unique identifier for each calendar in Outlook. You can use the calendar ID to specify which calendar you want to retrieve events from.

To get the calendar ID, you can follow this blog post about how to get the calendar ID. This will be needed for any group calendars since there is no way to get the calendar within the Power Automate user interface.

This will allow you to retrieve a list of all the group calendars available. These are all the groups in your tenant and not necessarily those you have access to.

You can then note the group ID for use in your flow to get events.

Get a Week of Calendar Events with the Get Events Action

To get a list of events from a personal calendar for a week in Power Automate, you can use the Get events action.

This action allows you to retrieve events from a specified calendar within a specified time range.

Follow these steps to use the Get events action.

  1. Add the Get calendar view of events action from the Office 365 Outlook connector to your flow.
  2. Select the calendar from which you want to retrieve events in the Calendar Id dropdown list. If you don’t find the calendar listed, you can choose the Enter custom value option and paste the appropriate calendar ID.
  3. Enter a Start Time in the format yyyy-MM-ddThh:mm:ss. This will filter on events with a start date after this time.
  4. Enter an End Time in the format yyyy-MM-ddThh:mm:ss. This will filter on events with an end date before this time.

You could also use the Get events action in the Office 365 Outlook connector to retrieve your events, but the Get calendar view of events action has the added convenience of the start and end time inputs to filter a specific time period of events.

It is worth noting that the Get calendar view of events action only retrieves events that are visible in the calendar view. If an event is not visible in the calendar view, it will not be retrieved by this action.

To ensure that you retrieve all events within the specified time range, it is recommended that you adjust the calendar view to show all events.

Get Next Week’s Events

You can of course use dynamic content or expressions In the Start Time and End Time fields to get next week’s events.

Here are the expressions you can use to get next week’s events.

@{utcNow()}

The utcNow function will return the current date and timestamp and this can be used directly as the Start Time input.

@{addDays(utcNow(),7)}

The addDays function can then be used to add 7 days to the current date and timestamp and this can be used as the End Time input.

This will return a week period of your calendar events.

Get Week of Events from Group Calendar with the Office 365 Groups HTTP Request Action

To get a list of events for a week from a Group Calendar in Power Automate, you can use the Office 365 Groups connector with the Send an HTTP request action.

This action allows you to make HTTP requests to the Microsoft Graph API and retrieve information about Office 365 Groups, including their calendars and events in those calendars.

To use this action, you will need to provide it with the URL of the API endpoint you want to retrieve data from, as well as any necessary authentication information.

https://graph.microsoft.com/v1.0/groups/{group-id}/events

For example, the above URL will retrieve a list of all events in the group calendar with the id {group-id}.

In this URL, you will need to replace {group-id} with the ID of the Office 365 Group whose calendar you want to retrieve events from.

The group ID or calendar ID will be a GUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

Follow these steps to use the Send an HTTP request action to get a list of events.

  1. Add the Send an HTTP request action in the Office 365 Groups connector to your flow.
https://graph.microsoft.com/v1.0/groups/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/events
  1. Add the above URL endpoint to the URI field. Replace xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx with your group ID.
  2. Select GET as the Method.

Once you have retrieved the list of events, you can then parse the response from the API and extract the information you need using the Parse JSON action.

Get Next Week’s Events

You can adjust the URL to filter the list of events returned to those with a start date in the next 7 days.

https://graph.microsoft.com/v1.0/groups/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/events?$filter=start/dateTime ge '@{utcNow()}' and start/dateTime le '@{addDays(utcNow(),7)}'&$orderby=start/dateTime asc

For example, the above URL will return the next 7 days of events from your group calendar.

  • ?$filter= the filter parameter is used to create an Odata filter to return only the specified events.
  • start/dateTime ge '@{utcNow()}' will return only the events with a start time greater than or equal to the current date and time.
  • start/dateTime le '@{addDays(utcNow(),7)}' will return only the events with a start time less than or equal to the current date and time plus 7 days.
  • &$orderby=start/dateTime asc is used to return the events in ascending order by start date.

This will return all the events for the next week from your group calendar.

Conclusions

Using Power Automate to get a list of events on a personal calendar for a week is a straightforward process. By using the Get calendar view of events action, you can easily retrieve the events from your Outlook calendars.

You can also use the Office 365 Groups connector to retrieve events from a group calendar. For this, you can use the Send an HTTP request action.

Did you need to get events from a group calendar? Did you know it was possible with the Office 365 Group connector? Let me know in the comments!

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Related Articles

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!