cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
leksi31
Frequent Visitor

Flow triggered by new record sending emails also after deleting that record

Hello all! 

 

I have a flow that is triggered when document or element has changed. It checks all the records in SharePoint and for those that have specific column changed it starts an approval action. Until the approval is not approved or rejected, flow is sending email notifications saying that you have approval pending with link to that approval. 

 

The problem comes when flow was launched and approval already went off/was activated, but it wasn't approved nor rejected and meanwhile that record for which flow is launching approval is deleted from Sharepoint. Email notifications are not stopping so flow just runs infinitely even though this record doesn't exists anymore and link of its approval is not active anymore. 

 

I wanted to add one more condition before sending email - something like "Check if this record is still in sharepoint / still exists" but I dont know how or if that's even possible. 

 

If anyone have a solution or any other advice about it, I would love to hear it. 

2 REPLIES 2
Taylor_Becktold
Resolver III
Resolver III

Hi @leksi31 -

 

I am assuming that your trigger provides a unique record id or path from SharePoint? If so, you could utilize parallel branching and a 'configure run after' setting to accomplish this.

 

Prior to any other actions in your flow, attempt to retrieve the document/item using an action like 'Get files' (depending on what you are doing this may be a different action). 

 

Add a parallel branch the same way you would add an action: 

Taylor_Becktold_2-1640114170743.png

I am using the 'terminate' action with the parameter of status set to 'cancelled'. This step will be used to make sure your flows don't register as failing when you are simply terminating them. 

 

Next, select the 3 dots on the corner of your terminate action and select 'Configure Run After' 

Taylor_Becktold_3-1640114344566.png

 

You can set the terminate action to only run when the 'Get' action you are using to find the record fails

Taylor_Becktold_4-1640114379037.png

 

This won't prevent the Flow from triggering, but will allow you to check for deletes and cancel the Flow before it attempts to process your deleted record further. 

 

Did my reply help? Please give it a thumbs up.
Did my reply answer your question? Please mark it as a solution!
If you liked my response, please consider giving it a thumbs up.

 

leksi31
Frequent Visitor

Thanks for response. Problem is that flow is not failing or whatever, because I have a loop that's sending emails until approval is or approved or rejected. 

 

Example: I have records with id 5, 6 and 7. They all started a flow and approval request. Until I don't approve/reject it, I am getting reminder emails every day for each. I approve approvals for id 6 and 7, so flow is finished and that works fine. I dont do nothing with one from id 5 though, so emails are still reminding me every day. Let's say I now delete record with id 5. Email reminders are still coming, flow is still working but record is deleted. How can I condition it to stop, if there is no more record (it's not existing anymore) with specific id. I cant use terminate brcause flow is stil working fine and all actions are successful. 

Helpful resources

Announcements
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.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (3,218)