Getting List Item Approval Status And Comments In FLOW

Currently, in MS Flow, we can just set the approval status for the list item. However, there is no provisioning action to get the approval status. After researching a lot, I have come up with a solution to this problem. This can only be achieved using SharePoint REST APIs.

Below are the steps to get the approval status and approval comments using REST API.

  1. Initialize the rest URL which has list name and item ID as input and internal names of the approval status and approval comments.

    Note
    Approval status retuned an integer value.

    Getting List Item Approval Status And Comments In FLOW

    Query text "_api/web/lists/getByTitle(‘list title')/items(@{triggerBody()['ID']})?$select=ID,OData__ModerationStatus,OData__ModerationComments"

  2. Click on "Add Action".
  3. Search "Send HTTP request to SharePoint" and select the same.
  4. Once the action is visible, provide the site URL.

    Getting List Item Approval Status And Comments In FLOW

    Let us configure the REST API now for the Get operation.

  5. Select method as ‘GET’ from the Method drop-down.

  6. In the URL section , select the REST String Variable from the "dynamic content" section populated just right bottom corner of the action. (It is the most common pathetic thing which I hate to do a lot of times in FLOW).

  7. Keep the header and body fields as Blank.

  8. Now, let us get the values from this Get call in the variable.

  9. Initialize the variables named varstatus and varAppComments as int and string respectively, under the value of varstatus.

    Getting List Item Approval Status And Comments In FLOW

  10. Select an expression from the dialog and start typing int().

    Getting List Item Approval Status And Comments In FLOW

  11. Once done, click on dynamic content.

  12. Select Body and you will be able to see the internal name in the expression textbox.

    Getting List Item Approval Status And Comments In FLOW

    int(body('Send_an_HTTP_request_to_SharePoint'))

  13. As we want to initialize only the status value for the variable, we need to get the single field by appending the below API. Let's append the varstatus odata value with an existing expression.

    "['d']['OData__ModerationStatus']"

    The complete expression will look like below.

    "int(body('Send_an_HTTP_request_to_SharePoint')['d']['Odata__ModerationStatus'])"

  14. For the comments variable, add the below value in the expression.

    body('Send_an_HTTP_request_to_SharePoint')['d']['OData__Moderation_comments']

Depending on the "Check" condition, you can choose your next action, such as -  sending mail for rejection or updating fields in SharePoint list item. 

 

Getting List Item Approval Status And Comments In FLOW