cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
skarthanal
Helper II
Helper II

Prevent duplicate flow runs when syncing events from Outlook Calender to SP Calendar

I have created a flow using the trigger When an event is added,updated or deleted V3 and everything works fine.  My issue is that flows are duplicated up to 3 times in certain cases and i cant seem to figure out how to prevent it from happening.  After digging i see that when an Outlook item is created the action type is "added" but the createdDateTime and lastModifiedDateTime are not the same (when the event is created, look below for example) which causes another flow to run right after this and then it loops up to 4 times.  How can i prevent this from happening using a trigger condition?  Please note that all actions are taken place in Outlook and not is SP.  Thanks!

 

When event is created in Outlook

createdDateTime:2022-05-27T14:00:39.4836234+00:00
 lastModifiedDateTime:2022-05-27T14:00:39.608613+00:00

4 REPLIES 4
eliotcole
Super User
Super User

Simple Fix

The simplest way is to just use the When a new event is created (V3) action from the Office 365 Outlook connector.

 

That will resolve your current issue.

 

---

Ongoing Solutions

EDIT - I've created and edited an event a couple of times, and it's not issuing multiple updates.

 

What I believe you have here is a rogue flow, add-in, or app.

 

Something is automatically updating all events in your calendar. It might even be an Office Add-In, or a 3rd-Party app.

---

 

But if you wanted to keep this for later management, you could temporarily use a trigger condition to stop it running if the create date and modified date are different. Then remove that later to add extra actions (for modifications) to the flow.

 

Or you could let the flow continue to run for each modification, and just put a simple condition at the start to check if it's been modified in the last 30 seconds.

 

I believe that there's a third option, which is hypothetical right now.

Hypotheticals

Let's pretend that (when creating a new event) Outlook actually makes 2 follow up edits to each new event, in all creating 3 modifications (original, +2) in the general scheme of things. This should mean that version 2 or 3 (dependent on 0/1 start) will technically be the first version of an event.

 

Here you could run a trigger condition to ensure that it won't run unless the version is 2.

 

I *believe* that's done in the etag, but I'll check and come back on that.

thank you for the reply.  I thought about separating my flows as you mentioned 1 for when an event is created and another one for when it is modified but both of those do not contain the "ActionType" which is what i need for my conditions to work.  How could i write a trigger condition based on if the last modified date is greater than 10 seconds of the create time, then run?

Just to be clear you want to only fire this for new events, and events modified 10s after the creation date, is that right?

 

I need to say this for my own peace of mind, but I think you should find out what is being modified in those immediate potential 4 updates in a few seconds. Once you have that, you should use that to build your trigger condition. Just ignoring 10 seconds could ignore valid updates.

---

Building Trigger Conditions

A trigger condition is placed in the settings of a trigger, simply accessed in the three dot menu:

Trigger Settings.jpg

 

To write a condition, you can type it in directly, but there's two easier methods.

 

1a - Write In The Expression Builder

You basically write the condition using the expression builder in a separate action (which you don't need to keep), then cut and paste it into the trigger condition field ensuring that it has an '@' before it.

 

Here I have built the trigger, and added the '@', too:

build trigger 0.jpg

 

1b - Potentially Easier Filter Method

 

So you can also choose to build it using a Filter action to help with some core logic.

 

Here I am mapping out that I want one thing (the last modified) to be greater than another (10s after creation):

build trigger 1.jpg

 

Once you have done the above, tap 'Edit in advanced mode' and cut the text from there:

 

 

build trigger 2.jpg

It even gives the '@'. 🙂

 

 

I've built my trigger, now I delete the Filter!

 

2 - Adding the Condition

So now you have built the condition, it's ready for the Trigger.

 

Here is an example of what yours might look like if you go for the 10 seconds route:

 

@greater(triggerOutputs()?['body/lastModifiedDateTime'], addSeconds(triggerOutputs()?['body/createdDateTime'], 10))

 

 

Here that is pasted into Trigger settings --> Trigger Conditions:

build trigger 3 - DONE.jpg

 

I tap 'Done' and I'm done.

 

Just to be clear you want to only fire this for new events, and events modified 10s after the creation date, is that right?

 

I need to say this for my own peace of mind, but I think you should find out what is being modified in those immediate potential 4 updates in a few seconds. Once you have that, you should use that to build your trigger condition. Just ignoring 10 seconds could ignore valid updates.

---

Building Trigger Conditions

A trigger condition is placed in the settings of a trigger, simply accessed in the three dot menu:

Trigger Settings.jpg

 

To write a condition, you can type it in directly, but there's two easier methods.

 

1a - Write In The Expression Builder

You basically write the condition using the expression builder in a separate action (which you don't need to keep), then cut and paste it into the trigger condition field ensuring that it has an '@' before it.

 

Here I have built the trigger, and added the '@', too:

build trigger 0.jpg

 

1b - Potentially Easier Filter Method

 

So you can also choose to build it using a Filter action to help with some core logic.

 

Here I am mapping out that I want one thing (the last modified) to be greater than another (10s after creation):

build trigger 1.jpg

 

Once you have done the above, tap 'Edit in advanced mode' and cut the text from there:

 

 

build trigger 2.jpg

It even gives the '@'. 🙂

 

 

I've built my trigger, now I delete the Filter!

 

2 - Adding the Condition

So now you have built the condition, it's ready for the Trigger.

 

Here is an example of what yours might look like if you go for the 10 seconds route:

 

@greater(triggerOutputs()?['body/lastModifiedDateTime'], addSeconds(triggerOutputs()?['body/createdDateTime'], 10))

 

 

Here that is pasted into Trigger settings --> Trigger Conditions:

build trigger 3 - DONE.jpg

 

I tap 'Done' and I'm done.

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (2,024)