“Why are the expired tasks still in the approvals list, why doesn’t Power Automate automatically remove them when it times out?”
If you’ve seen some expired approval flows, you’ve probably seen also the related approval tasks. If so, you probably also noticed that the tasks don’t go anywhere. Even though the flow was terminated, the approval tasks still behave like nothing happened. They stay in the list with all the other tasks waiting to be finished. The only difference being that nothing happens – there’s no flow waiting for them, they still exist and can be processed, but not by that flow.
That can be very confusing for users. Why do they still see the tasks that are not “active”? Shouldn’t they be removed from the list? How can you build a restartable flow if the old tasks stay in the system?
Important note: this solution requires Power Automate premium license!
To remove task you’ll need its ID
Since Power Automate doesn’t remove the tasks automatically, it’ll be up to you to remove them. The good news is that the tasks are just rows in the Dataverse table ‘Approval’. All you have to do is remove the corresponding row.
But to remove it you’ll need the approval task ID. Since the expectation is that the approval task will expire before the whole flow expires, you can’t use the ‘Start and wait for an approval’ action. If that action times out it won’t give you any outputs, not even the task ID. To get the task ID you must use the combination of ‘Create and approval’ and ‘Wait for an approval’.
Since the ‘Create an approval’ action will be successful, you can take the ‘Approval ID’ from there. Follow with the ‘Delete a row’ action that’ll run only if the ‘Wait…’ action times out and where you use the Approval ID to delete the task.
That’s it, now if the task expires the flow will automatically remove it from the task list.
You can use Power Automate to remove the expired tasks, but it’s more complicated than one might expect. The approach in this article is the simplest one – you completely remove the task, all links will stop working and it won’t appear in any task list. Yet it’s not perfect as it’ll still look as an active task in the email notification, but I didn’t find where that information is located so far…