Cancel approvals patttern

Cancel your pending approvals in Microsoft Flow

There are quite a few posts about approvals in Microsoft Flow. Have you ever noticed that when you have one of your flows sending an approval that there is no option to cancel the approval step?

No cancel option

In this post I’m describing one approach fro cancelling the approval steps so that you can resubmit the approval step.

Also, so far there isn’t an cancel approval step available yet in Flow. Hopefully it will arrive soon. So that I can avoid this pattern.

The Pattern

I’m going to start with the general pattern of the approval step and the cancellation of the same approval.

In my case the approval is initiated from a PowerApp. With the Create an approval I’m creating an approval.

This will create an entry within my common data services that presents the approval step to the user that needs to approve the action.

Then within my left branch I’m going to sit and wait for a response.

Cancel your pending approvals in Microsoft Flow 1

In the right branch I’m checking the current details of my approval task.

Get approval details

Once I get the details I set a variable to collect the current approval status. While waiting for a user to respond this will be set to Pending.

A Do until in the right branch will no check on a regular basis the status of my request again and again.

Cancel your pending approvals in Microsoft Flow 2

Now finally if the request was cancelled I need to terminate the flow that is running.

Cancel your pending approvals in Microsoft Flow 3

The terminate step in the above screenshot I’ve set to complete successfully. That way my flows will not fail.

Also note that the approval status is spelled Canceled rather than Cancelled.

Cancelling the request

To update the approval request in my Common Data Services, I’m creating a flow that takes an approval Id and then updated the Record in my CDS and marks it as cancelled.

In my case I’m using a flow to do this using the approval id from the request.

Cancel your pending approvals in Microsoft Flow 4

Please note that this approach may not be 100% supported as data in the CDS is directly updated

22 thoughts on “Cancel your pending approvals in Microsoft Flow

  1. Did you tested your “CANCELLING THE REQUEST” example?
    It does not work for me. the error:
    “192350006 is not a valid status code for state code msdyn_flow_approvalState.Active on msdyn_flow_approval with Id …”
    Any idea?

  2. Thanks for the quick answer.
    Numbers look OK:

    “_statecode_label”: “Inactive”,
    “msdyn_flow_approval_allowcancel”: false,
    “statuscode”: 192350006,
    “_statuscode_label”: “Canceled”,

    Could you PLS check if your example works and if so, please make a copy of your “Update a record” action. (Copy to clipboard (Preview))

  3. Hi Pieter,

    after spending some time It has worked also for me: I had to additionally update the following fields: “Completed On”, “Status value”: “Inactive” (!important), “Owner Type”: “systemuser”.

    Many thanks and cheers,

  4. Hi, i tried this solution but it didn’t work for me. Appers an error that says: “Principal user is missing prvWritemsdyn_flow_approval privilege”, i assume i have to give permission to the approvals entity… do you know where i have to give this permission?

    sorry for my english.

  5. Thanks for sharing. The issue I see with this stuff is it delays how quickly your approval reacts. With the do until limits for 5000 runs and 30 days, you can only check around every 10 minutes. So it’ll mean you could be waiting around for the flow to re check the attribute before the rest run, I want it instantaneous !

  6. Hi,
    Thanks for sharing the detail i am passing the ID and tried to update CDS record for that id but on the update statement i am getting 400 error.

  7. Please do! Some of the properties has changed. Not sure if this is still valid. If you can, please specify the values required for each property in the “Update a record” action.

  8. is there a way to get the response directly from the approval itself in flow, rather than getting into records?

  9. this means adding actions upon cancellation (update file property or delete) cannot be done without the steps in the article?

  10. Is there a way to cancel just one individual approval out of many multiple approvers that is expecting all users to respond? I am in need of something like this if a person is out. Thanks!

  11. How will this work? I am trying to think how to create this Approval status driven model. I can do a loop to do a “Create an approval” action for each user and do a “Wait for an Approval” out of the loop but I would need to assign an Approval ID. That won’t work properly bc Flow will continue on that assigned Approval ID when he approves. Also, when one person rejects, it won’t move on correctly. Too many moving parts.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: