Creating All-Day Event Using Power Automate

Introduction

Recently I came across a business use case, where the user wants to create events in the M365 calendar using the responses from the MS Forms. The events get created if the start date value and end date values are different. In this case, the end date is always greater than the start date. But if the start date and end date are the same, the user is getting the following error. In order to follow the steps, you need an M365 subscription from your organization, or you can sign up for free from the M354 developer program. 

Your request can't be completed. The duration of an event marked as All day must be at least 24 hours.

clientRequestId: d019fee2-45b4-4135-ab8e-4be48ce5dc1f

serviceRequestId: 032ef64b-f4fb-4312-a068-179172412c88

Below is the screenshot of the form. This is a pretty basic MS form and has the following fields,

  • Event Name
  • Start Date
  • End Date

Steps to design flow

Step 1

Manually Trigger a flow and here I have given the name ‘Create Event Test’.

Step 2

Chose the trigger from the available connectors forms, and chose ‘When a new form response is created’.

Now configure the form id to your form name,

the final configuration should look like below,

Step 3

Collect the form response. From the list of actions for ‘Form Connector’ select ‘Get Response Details’.

Step 4

Configure the form id to form name and ID to response ID.

The final action should look like below,

Note
The output from the form response is always in string format. Now we have to convert the value to UTC where the power automate understands. You do not have to use any expression. We will leverage the actions from the ‘Date Time’ connector where MSFT did all the work for us. All we have to do is configure this action to our needs. There is a much-advanced way of using expressions. You can refer more in the references section.

Step 5

Click on ‘New step’ and select ‘Convert time zone’ from the data time connector and rename it to ‘convert time zone – start date’.

Configure the values according to the following,

Base time

Select the start time value from the dynamic response output,

Source time zone

You can select the time zone according to your requirement. I have selected ‘Central Time’.

Destination time zone

You can select the time zone according to your requirement. I have selected ‘Central Time’.

Format string

You can choose patterns for your requirement. My requirement is to have the only Date and hence selected ‘Short date pattern’.

The final configuration should look below,

Step 5

Similarly, do the same steps for the End Date. The final action should look like below,

Step 6

Now look for action ‘Create Event (V4)’ under the ‘Outlook’ connector. Configure the actions accordingly.

Calendar id

Select calendar according to your requirement. Here I have chosen the default outlook calendar.

Subject

To make it unique I have selected the name of the event and submission time from dynamic form response outputs.

Start time

The outputs from the ‘converted time – Start Date’ action

End time

Here for the end time, I have to add a day since the flow starts counting from index 0. The expression here is addDays ((outputs from ‘converted time-end date’),1). below is the screen capture for reference.

Time zone

You can select any of the time zones. I have chosen ‘Central Time’.

Since our need is to create all-day events, click on ‘show advanced options’ for the action ‘Create Event (v4)’ and then select ‘All day Event’ property to Yes.

Step 7

The final flow design should look like below,

Testing

Now save the form and test it manually.

For different dates,

Outlook calendar Event,

For the same start date and end date,

Outlook Calendar Event,

Note: if you get the error:

“Your request can't be completed. The duration of an event marked as All day must be at least 24 hours.”

The above actions should resolve this issue. If you get stuck, you can refer to the attached flow package and import it to your environment to compare your design. 

References

  • https://powerusers.microsoft.com/t5/General-Power-Automate/Formatting-Date-And-time-in-MS-Flow/td-p/138363
  • https://support.microsoft.com/en-us/topic/how-to-customize-format-date-and-time-values-in-a-flow-34a91243-2961-d98c-c010-e385858b19cd
  • https://developer.microsoft.com/en-us/microsoft-365/dev-program 


Similar Articles