DEV Community

Kai Walter
Kai Walter

Posted on

Creating a daily sliding auto-blocker in Outlook 365 with Power Automate (Flow)


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

Flow overview


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.


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

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. Instead of the illustrated connector you would choose Office 365 Outlook.

Create the flow

On the Power Automate / Flow platform create a new flow Scheduled-from blank

New Scheduled-from blank screen

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

Get the AUTO-BLOCK calendar item

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

Get events settings

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

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

Update event settings

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:

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

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.

Top comments (0)