Power Automate — Automatically delete duplicate/clashing events from the SharePoint event calendar list

Emmanuel Adegor
5 min readApr 21, 2023

SharePoint Event Calendar is a powerful tool that allows teams to schedule and manage events. However, it can be frustrating when you accidentally create a duplicate event on the same date.

photo credit: google.com

Fortunately, with Power Automate, you can automate the process of deleting new events when there is an existing event for that date. In this blog, we will walk through the steps to create a Power Automate workflow that deletes new events on a SharePoint Event Calendar list when there is an existing event on the same date.

photo credit: google.com

Each SharePoint site provides an Events calendar list that allows users to create events, although users can also create their own event lists. However, within the scope of this post, I will not delve into this topic.

If you create events by using the events webpart on your SharePoint site page, they will be saved to this list. Alternatively, you can directly access the calendar view of this list.

Suppose a user adds another event to the list, they may not be aware that the same day has already been reserved. SharePoint permits multiple events to be added for the same day, as illustrated below.

You can set up a Power Automate workflow to delete a newly created event if it already exists.

How?

  1. Go to Power Automate and click on “Create” to create a new workflow.
  2. Select the “When an item is created or modified” trigger from the available triggers and select your SharePoint Event Calendar list from the “Site Address” and “List Name” fields.

By design, You will not find the events listed as part of the list names, so use the event list GUID instead:

  • Navigate to the SharePoint site where the events list is located.
  • Click on the “Settings” gear icon on the top right corner of the page and select “Site contents” from the drop-down menu.
  • Find the events list in the list of contents and click on the ellipsis “…”
  • Click “settings”
  • Once the events list settings page is open, the GUID will be displayed in the URL in the address bar of your browser. The GUID will be a long string of letters and numbers that follows the text “List=”.
  • Click “Enter custom values
  • Copy and paste the GUID of the events list

3. Next, add a “Get items” action from the SharePoint connector.

4. In the “Filter Query” field, enter the following query:

(EventDate le '@{triggerOutputs()?['body/EndDate']}') and (EndDate ge '@{triggerOutputs()?['body/EventDate']}') and (ID ne @{triggerOutputs()?['body/ID']}) and (Created lt '@{triggerOutputs()?['body/Created']}')

EventDate is the internal name of your “Start Time” column, while EndDate is the internal name of your “End Time” column. Not sure why Microsoft made it this way.

Photo credit: google.com

This filter query retrieves items from a SharePoint list that have a Start Date that falls within the range of the Start Date and End Date values of the current event being processed, excluding the current event itself, and that was created before the current event on the events list. This can be useful for retrieving clashing events or events that overlap in time with the current event been processed.

5. Next, add a “Condition” action from the Control connector.

6. In the “Condition” field, enter the following formula:

length(body('Get_items')?['value'])

7. Set the “Condition” field to “is greater than” and enter 0 in the value field.

The condition “length(body(‘Get_items’)?[‘value’]) is greater than 0 will help check if “Get Items” returned values

8. Add a “Delete item” action from the SharePoint connector.

9. In the “Site Address” and “List Name” fields, select your SharePoint Event Calendar list (paste the GUID of the list in list name field).

10. In the “Id” field, select “Id” from the “Dynamic content: when an item is created or modified” dropdown list.

Here is a screenshot of the workflow:

If your events exceed the 5000 list view threshold, add a value between 200–10000 in the “Top Count” field, add the value “Modified desc” to your “Order By” field then add the “Get Items” pagination of the same number as your “Top Count” field. Click here to read my article that explains how to paginate get items action.

Conclusion:

Using this workflow, you can delete newly created events automatically if they conflict with an existing event on the same date. Additionally, you can incorporate a “Send an email v2” action to notify the user about the conflict and prompt them to choose another date, while also informing them that the original event has been deleted.

--

--

Emmanuel Adegor

SharePoint Developer | React JS | SPFX | SharePoint Administrator