Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Delete SQL Row when Task is removed from the Planner list of tasks

(0) ShareShare
ReportReport
Posted on by

I Created a flow that gets all the Tasks from Microsoft Planner and Add them as rows in a SQL Database. I am trying to Create a flow that tracks if a Task was deleted from the Planner or it deletes the row from the SQL Database as well. 

 

Please help me!

 

Screenshot 2020-04-07 at 10.25.26.pngScreenshot 2020-04-07 at 10.29.06.png

  • JohnAageAnderse Profile Picture
    1,986 on at
    Re: Delete SQL Row when Task is removed from the Planner list of tasks

    @v-alzhan-msft (Alice)

     

    I would suggest to move the action List tasks out of the loop, as it will always get all tasks in the planner, so no need to place it inside the loop.

     

    Can you clarifiy - do you know if using a Filter action is faster than a loop getting all values into an array and then using contains in a condition? (just curious)

     

    Kind regards, John

  • Verified answer
    v-alzhan-msft Profile Picture
    on at
    Re: Delete SQL Row when Task is removed from the Planner list of tasks

    Hi @hadibook ,

     

    Please refer to screenshot below to create the flow:

    1.png

    Please make sure there is a column has the same value with the Id of the task, and the column value would be unique, then you could check from each row in the sql table, to see if there is a task in the planner has the same id with the row in the Filter Array action, and if no, delete the row in the sql table.

    The length expression in the flow as below:

    length(body('Filter_array'))

     

    Best Regards,

    Alice

     

    Community Support Team _ Alice Zhang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • JohnAageAnderse Profile Picture
    1,986 on at
    Re: Delete SQL Row when Task is removed from the Planner list of tasks

    Hello @hadibook 

    You are using two loop to process all the Planner tasks and all the SQL table rows, which will take a long time 🙂

     

    Simplify it by first doing this:

    1. After the List tasks action, initialize an array variable
    2. Use an Apply to each loop to add each Planner task id to the array variable (append to array variable).
    3. You now have all the active Planner task ids in the array variable.
    4. Now comes your action to Get SQL tasks.
    5. Keep your Apply to each loop for the SQL tasks.
    6. Replace the inner loop with a condition - Array variable, Contains, Task ID
    7. If yes, do nothing
    8. If no, delete the SQL task

    By not using a loop within a loop, you will save a lot of time.

    Kind regards, John

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow