How To Get Approval Comments In Power Automate

How To Get Approval Comments In Power Automate

Power Automate approval comments can retrieved from an approval action and copied into a SharePoint list or document library. The tricky part is comments are stored inside of an array due to approvals having multiple potential approvers. We must convert the the array of of comments into multiple lines of text and then it is possible to write the comments back to SharePoint.

Table of Contents
• Introduction: The Approval Flow With CommentsSetup The SharePoint Document LibraryBuild A Power Automate Flow To Get Approval CommentsRun The Power Automate Flow To Get Approval Comments




Introduction: The Approval Flow With Comments

Managers at a food distribution company use Power Automate to obtain invoice approvals. They can leave comments on an approval to ask for more details.



When comments added are to an approval Power Automate updates metadata for the file in SharePoint to include the comments.




Setup The SharePoint Document Library

Create a new SharePoint document library named Invoice Approvals with the following columns:

  • Name
  • Approval Outcome (single line of text)
  • Comments (multiple lines of text)




Build A Power Automate Flow To Get Approval Comments

Open Power Automate and create a new automated flow. Trigger the flow when a file is created in SharePoint and add an action to start and wait for an approval. Once the approval is accepted or rejected by the approver(s), the approval comments will be returned to Power Automate as a property of the start and wait for approval action.

Approval comments are stored in an array because one or more approvers can respond to an approval. We want to convert the array to multiple lines of text. To do this, we add a Compose action with the Responses Comments as an Input. Then Power Automate places it inside an Apply To Each action to operate on the array of comments values.



Then we add a SharePoint – Update File Properties action and use this code in the comments field to convert the comments array into multiple lines of text. The decodeURIComponent function is used to add each comment on a new line.

join(outputs('Compose:_Comments'),decodeUriComponent('%0A'))




Run The Power Automate Flow To Get Approval Comments

It’s time to test the flow we’ve built. Turn the flow on and place a new file into the SharePoint document library.



The approval is sent the approver in Microsoft Teams. The approver writes a comment and selects approve.



Then the Power Automate flow updates the approver comments alongside the document in SharePoint.




Questions?

If you have any questions or feedback about How To Get Approval Comments In Power Automate please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

10 Comments
Oldest
Newest
Inline Feedbacks
View all comments
David Hock
27 days ago

If it’s a “First to respond” type of approval, I’ve also used “first(outputs(‘Start_and_wait_for_an_approval’)?[‘body/responses’])?[‘comments’]” directly in the Update Item/File Properties action, in order to avoid the automatic Apply to each that gets created when you add the Responses Comments (just to keep things a little cleaner/shorter). But if there are multiple approvers, I like your approach, so thanks for sharing. It could also be used in an email to the requester.

Harishkumar Rajan
Harishkumar Rajan
27 days ago

Nice! Is there a way to make this comment mandatory?

Kevin Zollinger
27 days ago

I used this process with almost every approval workflow I build. I’ve gotten in the habit of using that one multi-line column for every approver’s comments. In that case I append the date, the approver and the outcome before the comment and then end it with a new line so it’ll look good in the list. I have one approval process that can go to up to 8 approvers multiple times and by collecting their comments we can easily track what has happened. I also send the comments with each new approval request. It is super slick.

David Howe
David Howe
26 days ago

Kevin,
I like the idea of appending the date, the approver and the outcome before the comment and then end it with a new line. Can you provide some more details on how you do that? Thanks.

Kevin Zollinger
25 days ago
Reply to  David Howe

It looks something like this image. Comments are the previous set of comments that we are going to append to. Outcome, in this case might be any one of 5 results based on the step in the overall process. Date time is pretty self explanatory. The next two are the responders display name and the actual comment followed by a variable holding a new line to make it pretty.

Hope that helps!

Screenshot 2024-08-21 125130.png
David Howe
David Howe
25 days ago

Yes, very helpful. Thank you.

David Howe
David Howe
26 days ago

Thanks, Matthew. I was hoping you could clarify something for me on your approach. Am I correct in saying that this approach is only necessary in the scenario where you have assigned an approval to multiple people? Its not clear to me because it looks like your example is only assigned to one person. I have a similar set up with an approval assigned to a single person and have the dynamic content for comments directly in the Comments column and it works just fine without the compose action or join function.

David Howe
David Howe
25 days ago

I followed the steps you laid out and ran into trouble with the join function. The error said the first parameter of the function must be an array but the output of the Compose:_Comments is a string. I modified by creating an array variable and appending comments to the array variable, then passing the variable as the first parameter of the join function.