Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - General Discussion
Answered

How to set content approval status action from a variable?

(1) ShareShare
ReportReport
Posted on by 166

In power automate, I am using the content approval status action, and the action is defined as a variable. Basically this table

 

https://docs.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.spmoderationstatustype?view=sharepoint-server

 

I can make it send either a number or value from the client side to power automate. But the problem is for the variable in action (highlighted in the picture), what value and data type do I need to set to be compatible? I am putting numbers in it but it is not working.

 

 

approval.PNG

  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at
    Re: How to set content approval status action from a variable?

    @R58395 

     

    In case for your convenience I did make a detailed test on my side and here are my findings about your question:

     


    @R58395 wrote:

    what value and data type do I need to set to be compatible? I am putting numbers in it but it is not working.

     

     

    approval.PNG


     

    1) Yes, it is possible to use a value there instead of going into multiple  almost identical action blocks with branches and predefined dropdown values, if you really want to. Here are the values to use, which I tested on my side and I was able to get it to change the test Sharepoint List Item's Approval Status:

     

    It is pretty simple in this case - just use

    0 for Pending

    1 for Approved

    2 for Rejected

     

    Here are my results after testing with example below and when the Approval status was something other than what it was before:

     

    For Pending

    0

    81521-approv-02.png

     

    Result:

    81521-approv-03.png

     

     

     

    For Approved

    1

     

    81521-approv-04.png

    Result:

    81521-approv-05.png

     

     

    For Rejected

    2

    81521-approv-06.png

     Result:

    81521-approv-07.png

     

     

    So in short:

    0 - Pending

    1 - Approved

    2- Rejected

     

     

    In the above, although I use Compose, if you use a Variable  of type Integer it should work, I tested with the below, where a Variable was initialized to value of 1, and then used in the Set content approval status action block, and it worked to change from Pending to Approved:

     

    81521-appr-0b.png

     

    When I tested the above it worked and changed the test item from Pending, to Approved after running the Flow.

     

    Please note the following caveat:

    If setting to Rejected specifically first, then trying to set same item to another status, there will probably be BadGateway and infinite retry and the status will not change, unless using the SharePoint UI to put it back to another status than Rejected first (such as Pending). 
    However, note that according my testing this behavior is exactly the same even if doing this with the pre-populated values from dropdown, though, by the way!

     

     

    2) Note that for context, the following is presumed:

     

    81521-appr-0a.png

     

    81521-approv-01.png

     

     

     The library's "Settings -> Versioning Settings" should be set to Yes for "Require content approval for submitted items?" 

     

    @v-yuazh-msft already did really great job explaining these steps in more detail, in their post here:

    Flow Issue: Conditions Not Specified 

     

    You may either refer to the post above, or alternatively refer to docs.microsoft.com  - Require approval of documents in SharePoint using Power Automate

    to find out how to go to Settings > Versioning settings > Require content approval for submitted items and set it to Yes, which is required prior to using "Set content approval status" from Power Automate - otherwise, that Action will return with an Error status that "Content moderation is not enabled on the library".

     

     

    If you encountered any issue using these numbers above, please check the above thoroughly (especially pay attention to what happens if the Item was already rejected for example above) and also check that you are editing the correct item ID. Show the ID column in SharePoint list and then test with hard-coded sample item ID value and also hard-coded value (0,1,2) for Action to make sure it is working, then try it with the dynamic values or expression after that.

     

    During the test, to isolate the cause better, also please make sure to leave Comments field blank, etc. when you are testing as well.

     

    Check if it helps @R58395 - if you use the way above, you can do it without using multiple Action blocks and do it the way that it seems like you prefer most instead.

     

     

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at
    Re: How to set content approval status action from a variable?

    @R58395 

     

    From Set content approval status Action (docs.microsoft.com)

     

    action-content-approval-status

     

    Notice it is a set of two choices from Flow Action from a dropdown.

     

    This is a special data type and it is not expected to put an expression here usually, but to select from the two predefined choices in most scenarios.

     

    I recommend (even if it may seem redundant) to have a condition and two branches with same content but a difference in only Approve versus Reject specifically in there. It also is a little bit safer and not so subject to a set of nuances of that specific value. Sure, there are two blocks to maintain, but there would be less to worry about regarding the specific nuance of forcing a value into the one that expects pre-selecting one of the dropdown choices

     

    In the case you really want to use a dynamic value anyway  - while it is not supported "out of the box" in Flow, I believe it might be possible to do this if the expression you put in there is formatted in a very specific way.

     

     In case you want to know that very specific way reply here but first you can try the way suggested above - the way using the special formatted value require a lot of attention to a specific detail in formatting the value, and can be more error-prone if not careful. For some of these kinds of things it requires the Send a HTTP Request to SharePoint action instead (but in this case, it may be possible with the Set content approval status action you are using now, if that field has a very specific expression) . In case you really want that way and want to not have two action blocks and a condition block, but absolutely are sure you want the way that uses one block, and a specific formatted value forced in there for Approve or Reject based on a step above, reply in case and I might go ahead and check on it.

     

    Otherwise please check if the idea above with the condition is something you prefer. 

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1