Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Triggers
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
  • Get help with flow
Menu

How to set Content approval status with Power Automate

Posted on October 10, 2021January 6, 2022 by Tom

“When I use the Set Content Status Approval action to change the approval status to Approved, the Power Automate flow just hangs there with a Bad Gateway error on that action”


If you decide that the simple content approval in SharePoint is not enough, you can replace it with Power Automate flow. And in that flow you’ll use the ‘Set content approval status’ to update the status at the end. You probably won’t encounter any problems if a SharePoint library allows only major versions. But once you allow minor versions, the action can cause problems. The action might end with “BadGateway” and the whole flow will fail.

Power Automate content approval status

What’s the problem?

When setting the content approval status, it must go in a specific order. The document starts as ‘Draft’. Once it’s submitted for approval, it’ll go into ‘Pending’ status. From there it can be ‘Approved’ or ‘Rejected’. You can’t skip the order. If document is in ‘Draft’, you can’t approve nor reject it directly. It must be in the ‘Pending’ status before that.

That’s very often the problem. If you’re building your own approval flow, you must go through all the states. Don’t approve/reject directly, set the status ‘Pending’ with the ‘Submit’ action first.

Document update in the flow

It’s not only at the beginning of the flow to inform users, you should update the status after each update, e.g. when you update the approval information. If you enable content approval and minor versions, then each update will turn the document back to ‘Draft’. Even updates by Power Automate. And as already explained above, you can’t approve/reject document directly from ‘Draft’ status. The content approval process must always follow the same steps: Draft -> Pending -> Approved/Rejected. Translated to the ‘Set content approval status’ action: (create/update) -> Submit -> Approve/Reject.

Summary

If you use Power Automate flow to replace the standard content approval process, you must follow the status order. If document is in status ‘Draft’, you must ‘Submit’ it for content approval. Only documents in ‘Pending’ status can be approved or rejected. And the important point – each update in the flow will turn the document back into ‘Draft’. That means you must set it back to ‘Pending’ before the final approval/rejection.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

10 thoughts on “How to set Content approval status with Power Automate”

  1. Julie says:
    October 14, 2021 at 3:05 pm

    When automating content approval for an item in a list, rather than a file in a library, how to get the eTag?

    Reply
    1. Tom says:
      October 16, 2021 at 9:26 pm

      Hello Julie,
      ETag is needed only for files. Items don’t have an ETag, keep the field empty.

      Reply
  2. Brooke says:
    October 20, 2021 at 11:08 am

    Hi,
    I am using a Sharepoint List (enabled content approval) and need to automatically trigger an approval for each submission.
    Based on approval status, i want to ‘set the content approval status’ to Approved/Rejected but i am getting the Bad Gateway error. Can you please help?

    Reply
    1. Tom says:
      October 24, 2021 at 11:29 pm

      Hello Brooke,
      with SharePoint list items it should be very straightforward, I’d just check if:

      • the action is properly configured
      • if the account running the flow has permissions to approve the item (in the versioning settings)
      • if somebody didn’t change the status manually before the flow tried to update it
      Reply
  3. Lydia says:
    January 27, 2022 at 12:51 pm

    Hi,
    When a document is in the approval/reject status, I still need it to be available without the modifications? Can this be done by manually customising current flows? e.g. copy the document?

    Reply
    1. Tom says:
      January 29, 2022 at 7:13 pm

      Hello Lydia,
      I don’t understand what you’re trying to achieve. If the file is approved/rejected, it’s fully available. You just need to approve it again after each change.

      Reply
  4. Ian Fraser says:
    February 23, 2022 at 12:54 pm

    Hi thanks for the article – its exactly what I’m seeing. in our environment.

    Our flow has been forced back to Draft as someone edited the document while in the workflow (so change from pending to draft). Then we got the bad gateway and the 502 / 500 inner error when it went via the approval steps:

    {
    “error”: {
    “code”: 502,
    “source”: “uk-001.azure-apim.net”,
    “clientRequestId”: “776fc4bc-e2d4-4f61-94ea-2186ae713461”,
    “message”: “BadGateway”,
    “innerError”: {
    “status”: 500,
    “message”: “The current state of the item is Draft and the following action Approve cannot be implemented\”\r\nclientRequestId: 776fc4bc-e2d4-4f61-94ea-2186ae713461\r\nserviceRequestId: 776fc4bc-e2d4-4f61-94ea-2186ae713461”
    }
    }
    }
    I’m sure its me but I dont quite see from your article how i would stop this happening but our flow is on sharepoint file approaval as follows:

    When an item of file is modified (wait for pending using a trigger on the advanced config)
    Get file metadata (gets the etag etc)
    Start and wait for the approval
    Condition (approved or not approved)
    YES: Set content approval status (this is where we get the bad gateway

    Do you know the best way to ensure the draft change effectively ends the approval flow? We can start again with a submission to change it to pending via the Sharepoint portal submit for approval button.

    Thanks

    Ian

    Reply
    1. Tom says:
      February 27, 2022 at 7:42 pm

      Hello Ian,
      you can’t stop it from happening, that’s standard SharePoint functionality. If there’s a need to approve content in a document library, every change in the document will move it back to ‘Draft’. The only thing you can do is to set it back to ‘Pending’ after each update and then ‘Approve/Reject’.

      Reply
    2. David says:
      December 25, 2022 at 2:25 am

      I perform a checkout in the beginning of the flow and check it back in at the end where i then immediately submit and then approve/reject. The document being checked out at the beginning sets it to draft so it is in the expected draft state when you reach the end steps.

      Another benefit of checking it out is that you can update properties throughout the flow without going through the submit step each time. I update a separate column with the pending status so the end user knows what is going on while the checkout icon is present and regular column shows draft.

      Reply
  5. Michael Berry says:
    April 19, 2022 at 12:23 am

    Thank you very much! I’ve been grappling with this for hours, and the update properties made all the difference!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


NEW! Master the HTTP requests to SharePoint with a new cheat sheet!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Use Power Automate to forward Outlook events upon registrationJanuary 29, 2023
  • Why the condition is false for the same numbers (Power Automate)January 25, 2023
  • How to forward event invitation to other calendar (Power Automate)January 22, 2023
  • Run ‘For selected item’ flow from non-default environment (Power Automate)January 18, 2023
  • Hide button in SharePoint list after Power Automate flow startedJanuary 15, 2023

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes