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.
- 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.
Query text "_api/web/lists/getByTitle(‘list title')/items(@{triggerBody()['ID']})?$select=ID,OData__ModerationStatus,OData__ModerationComments"
- Click on "Add Action".
- Search "Send HTTP request to SharePoint" and select the same.
- Once the action is visible, provide the site URL.
Let us configure the REST API now for the Get operation.
- Select method as ‘GET’ from the Method drop-down.
- 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).
- Keep the header and body fields as Blank.
- Now, let us get the values from this Get call in the variable.
- Initialize the variables named varstatus and varAppComments as int and string respectively, under the value of varstatus.
- Select an expression from the dialog and start typing int().
- Once done, click on dynamic content.
- Select Body and you will be able to see the internal name in the expression textbox.
int(body('Send_an_HTTP_request_to_SharePoint'))
- 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'])"
- 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.