Yes, there are a few ways to delete or cancel a Teams approval request from Power Automate, but the method depends on the state of the approval request and what you want to achieve.
Note: Questions related to Power Platform (Power Automate) must be posted to the Power Platform Community https://community.powerplatform.com/ to get more relevant and appropriate results.
Understanding the Limitations:
- No Direct "Cancel" Action for Pending Approvals: Power Automate doesn't have a built-in action to directly "cancel" a Teams approval request that is still in a "Pending" state and awaiting a response from the approvers. Once initiated, the approval flow is waiting for one of the outcomes (Approve, Reject, Reassign).
- Deleting the Approval Instance: You can delete the instance of the "Start and wait for an approval" action in your Power Automate flow, but this won't recall or cancel the already sent request in Teams for the approvers. They will still see and be able to act on the original request.
Workarounds and Potential Solutions:
Here are the approaches you can take, depending on your specific needs:
1. Preventing the Approval Request from Being Sent in the First Place (Best Practice):
The most effective way to "cancel" is to prevent the approval request from being sent if certain conditions are met. You can achieve this by adding conditional logic before the "Start and wait for an approval" action:
- Add a "Condition" control: Before the approval action, add a "Condition" that checks if the criteria for needing the approval are still valid.
- If the condition is false (meaning approval is no longer needed): The flow will branch away from the "Start and wait for an approval" action, effectively preventing it from being sent. You might want to add a step here to update a status field or log the reason for not sending the approval.
2. Handling "Expired" Approvals (If Time-Based Cancellation is Needed):
You can configure the "Start and wait for an approval" action to have a timeout duration. If the approvers don't respond within this timeframe, the flow will proceed with the "Timed out" outcome. You can then handle this outcome as a form of cancellation:
- Configure Timeout: In the settings of the "Start and wait for an approval" action, specify a value for "Timeout" (e.g., PT1H for 1 hour).
- Handle "Timed out" Outcome: In the "Switch" or "Condition" control following the approval action, handle the "Timed out" outcome according to your requirements (e.g., update a status, notify someone).
3. Using Adaptive Cards and Custom Actions (More Advanced):
This involves more complex development but can offer more control:
- Send an Adaptive Card for Approval: Instead of using the built-in "Start and wait for an approval" action, you can construct and send a custom Adaptive Card to a Teams channel or user using the "Post card in a chat or channel" action.
- Capture Responses: You'll need a way to capture the responses to this Adaptive Card (e.g., using Power Automate buttons that trigger another flow or update a Dataverse table).
- Implement Cancellation Logic: You can include a "Cancel" button in your Adaptive Card that triggers a separate process to update the relevant records and inform the initiator and potential approvers that the request is no longer valid. This requires managing the state and logic yourself.
4. Deleting the Approval Instance (Doesn't Cancel in Teams):
As mentioned earlier, you can delete the run history of your Power Automate flow. If the flow is currently waiting at the "Start and wait for an approval" action, deleting the run will stop the flow instance. However, the approval request will still exist in the approvers' Teams environment.
5. Using Dataverse (If Approvals are Stored There):
If your approvals are being stored in Dataverse (which is common with the built-in approvals), you might be able to update the status of the approval record directly using Dataverse connector actions. However, this is generally not recommended as it bypasses the intended approval workflow and might not properly notify the approvers or update related systems.
Which Method to Choose?
- Preventing the request (Method 1) is the cleanest and most recommended approach. Design your flow to only initiate the approval when necessary.
- Handling timeouts (Method 2) is suitable if you need a time-based cancellation mechanism.
- Adaptive Cards (Method 3) offer the most flexibility but require more development effort.
- Deleting the flow instance (Method 4) should generally be avoided as it doesn't truly cancel the Teams request.
- Direct Dataverse manipulation (Method 5) is not recommended due to potential inconsistencies.
In your case, to "cancel" an already sent request, your options are limited. You can't directly recall it with a built-in action. Your best bet would be to:
- Communicate directly with the approvers in Teams and ask them to disregard or reject the request.
- If the approval has a timeout configured, wait for it to expire.
- For future scenarios, implement conditional logic before the approval action to prevent unnecessary requests.
While a direct "cancel pending approval" action would be useful, the current Power Automate capabilities require these workarounds. Consider submitting a feature request to Microsoft if you believe a direct cancellation action is crucial for your scenarios.