function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kathleen Elisabeth SmithKathleen Elisabeth Smith 

Get & Delete Tasks Related to Record that Triggered the Flow

I'm creating a record-triggered flow that is supposed to trigger every time an Account record is updated, when the checkbox field "Good to Clean" equals "True". From there, it is supposed to:
  • Get Records: gets tasks where the WhatID equals the Account ID
  • Loop: Loops through the record collection to delete each task record 
  • After Last Item it Gets Records: gets tasks where the WhoID equals the Contact ID
  • Loop: Loops through the record collection to delete each task record
  • After Last Item: it updates the "Good to Clean" field and sets to "False"
Below is an image of what the flow looks like currently. The loops are using the collection variables created by the Get Records). I added the loop in because I was getting the "Too many DML rows" error. The delete is set to run on the current item from the loop. 
User-added image

However, when I debug the flow, it gets stuck after the delete records. When I run the flow itself in my Sandbox, it only deletes 1 record that is unrelated to the account that triggered the flow. Below is a picture from the debug log. The account that triggered the flow only has 3 tasks on it, so it shouldn't be grabbing that many.
User-added image

Would someone be able to help me out and see where I'm running into the issue so that it doesn't grab the tasks related to the account that started the flow?
Kathleen Elisabeth SmithKathleen Elisabeth Smith
User-added image
I updated the flow and combined the two Get Records. Still running into the same issue when debugging. Here are two photos, one of the getter and one of the contact variable.

User-added imageUser-added image
Soren OrionSoren Orion
Not sure if you ever found an answer to this but it looks as though your loop isn't fully connected. The flow goes from 'Loop to Delete Tasks' to 'Delete Records' and stops there. You would need to connect Delete Records back to the Loop. So it looks like Loop to Delete Tasks ⇄ Delete Records. Right now it only looks like Loop to Delete Tasks → Delete Records