Creating a daily sliding auto-blocker in Outlook 365 with Power Automate (Flow)
Tags: office365
Published: 2019-12-08 18:53:50

---
title: Creating a daily sliding auto-blocker in Outlook 365 with Power Automate (Flow)
published: true
description: Use Microsoft Power Automate to create an all-day auto-blocking calendar event that is automatically sliding to the new day.
tags: office365
---

# TL;DR

In this article I want to show how to [create an automated flow with Microsoft Office 365 Power Automate and Outlook](#start) that - on a daily schedule - picks a calendar item intended as a daily blocker and moves it to the next day.

![Flow overview](https://thepracticaldev.s3.amazonaws.com/i/cbxmn0qy5hvlevfgsxwk.png)


# Rationale

Meetings are important to define, align or coordinate ideas & work across organizations and disciplines within an organization. Granted.

Meeting invitations dropping in throughout days or weeks seem harmless first - the further away these meetings are scheduled in the future - but on each new day, it seems that this particular day is already filled-up with meetings that would not allow fulfilling on commitments made in other meetings or elsewhere. I guess this not only applies to me?

Then having other meeting requests coming in and picking out remaining slots on short notice can mess up whatever planning one has conducted on the previous day or start of the day. Various tactics can be applied to conquer this dilemma. One of these can be to fill up the calendar with fixed blocks in advance that would potentially allow on that day to have some time left for getting things done.

In my internal wiring I'm a software developer. Creating blockers - especially manually - is totally out of question for me. In the past years one could have implemented a more adaptive blocking approach by utilizing macros - if the particular platform would allow for those. Today, with enterprises moving also productivity tools into the cloud, tools become available that offer a more simplistic approach to implement an **adaptive calendar blocking**.

# Block the current day

This article is supposed to be the first one in a series showing how adaptive blocking can be achieved. I want to start with the most simple scenario: just move an all-day calendar block from day to day to at least raise the barrier for people just randomly hijacking remaining time slots.

Although I'm using _Microsoft Office 365 Outlook and Power Automate (aka Flow)_ -  available in the  enterprise context I work in, I'm sure it can be achieved with other tools and platforms as well.

## Prerequisites <a name="start"></a>

## Preparation 1 - create an AUTO-BLOCK all-day event

For the current day create an all-day event with subject `AUTO-BLOCK`, mark it as `busy`. Choose whatever subject you like - it just needs to align to the flow you create below.

## Preparation 2 - create an Office 365 Outlook connection

Either jump right into the action below or make yourself familiar with the concepts of the Office 365 Outlook Connector first [here](https://docs.microsoft.com/en-us/connectors/office365connector/)

Have or create this connection in advance or create it along with the creation of the flow. Creating a connection is explained in this [documentation entry](https://docs.microsoft.com/en-us/power-automate/add-manage-connections). Instead of the illustrated connector you would choose `Office 365 Outlook`.

## Create the flow

On the [Power Automate / Flow platform](https://flow.microsoft.com/) create a new flow `Scheduled-from blank`

![New Scheduled-from blank screen](https://thepracticaldev.s3.amazonaws.com/i/l39ne3njph8hdwzd853l.png)


Name the flow and give it a daily schedule - 1:00 AM should be an OKish time to move the daily blocker.

![Schedule settings screen](https://thepracticaldev.s3.amazonaws.com/i/em6r812nxau5nc024fm2.png)

## Get the AUTO-BLOCK calendar item

Add a `Get events`(Office 365 Outlook) action to the flow.

![Get events settings](https://thepracticaldev.s3.amazonaws.com/i/u8niws17wpf9cl7dq4zo.png)

Select your calendar, filter by `Subject eq 'AUTO-BLOCK'` and set the `Top count` to `1`.

## Modify the calendar item

Because `Get events` returns an array of data, add an `Apply to each` action to loop through this array. Select `value` from the previous output step.

![Apply to each settings](https://thepracticaldev.s3.amazonaws.com/i/isd3l68jtf2xbg0my3gj.png)

Within this loop add an `Update event`(Office 365 Outlook) action.

![Update event settings](https://thepracticaldev.s3.amazonaws.com/i/9xuwricle5mr3lv8h799.png)

Additional to `Calendar id` and `Id` set these fields:

- `Subject` - select `Subject` from the `Get event` dynamic content
- `Start time` - set to dynamic expression `utcNow()`
- `End time` - set to dynamic expression `utcNow()` or e.g. `addDays(utcNow(),1)` if you need a 2 days blocker
- set `Is all day event` to `Yes`
- set `Show as` to `Busy`

When calling `peek code` on this action, `inputs.body` should look like this:

```json
        "body": {
            "Subject": "@items('Apply_to_each')?['Subject']",
            "Start": "@{utcNow()}",
            "End": "@{addDays(utcNow(),1)}",
            "IsAllDay": true,
            "ShowAs": "Busy"
        },
```

**Save** the flow and you're good to go. 

With **Test** you could set your `AUTO-BLOCK` to any calendar date and check if it is moved correctly.