Display approval history in a simple, user friendly way via Power Automate

“Is there a way to display approval history in some way that’s easy to read for the users when using Power Automate? Maybe directly in the SP list?”


Using Power Automate, the whole approval history for everything is in one place. Power Automate -> Action items -> Approvals -> History. But I don’t think it’s really user friendly if you need a quick overview, or if you need to share it with other users. It’s much better to keep the approval history directly in the item/document itself, and that’s the goal of this post.

Prerequisite: ‘Multiple lines of text’ column with ‘Enhanced rich text’ enabled to store the history.

Building ‘Approval history’ table

We’ll need a variable dedicated to building the Approval history table, let’s call it ‘ApprovalHistoryTable’. The Approval history table is using HTML elements (that’s why the column has to be enhanced rich text), so during the initialization we can already put the first HTML elements in it. The code below will start the table and add the headers Date, User name, Response and Comments to it.

<table><tr><th>Date</th><th>User name</th><th>Response</th><th>Comments</th></tr>

We can also initialize one more string variable that will be needed later. Let’s call it ‘DateToFormat’ and we’ll use it to format the date in a user readable way.

With this we’re ready to skip a bit in the flow, right after the ‘Approval’ action.

Add ‘Approval history’ line for each step

The ‘Apply to each’ action where you’re processing all the approval ‘Responses’ is our next target.

This is the moment when we’ve got all the information we need for the table. The first step is to store the response date into the ‘DateToFormat’ variable. It is necessary as we can’t apply the formatDateTime() expression on the response date, but we can apply it on a variable.

The second step is to add another line in HTML format to our ‘ApprovalHistoryTable’ using the ‘Append to string variable’ action.

<tr><td>[formatDateTime(variables('DateToFormat'), 'yyyy-MM-dd HH:mm')]</td><td>[Responses Approver name]</td><td>[Responses Approver response]</td><td>[Responses Comments]</td></tr>

Notes:
[formatDateTime(variables(‘DateToFormat’), ‘yyyy-MM-dd HH:mm’)] is an expression using the ‘DateToFormat’ variable, you can format the date/time as you wish. You can find more formatting options in my previous post.
[Responses …] are all dynamic content from the ‘Start and wait for an approval’ action.
[] are used only for graphic representation of the expression and dynamic content, they’re not part of the code.

Update the ‘Approval history’ into the item

Once we have the new lines in ‘ApprovalHistoryTable’ variable, we can update it in the item. You can use either the ‘Update item’ action, or HTTP request to update that single column. Just don’t forget to add </table> at the end to close the table.

The order of the actions that create the approval history table is below.

Summary

I consider the ‘Approval history’ solution described above as a baseline for any approval process. I don’t expect users want to go to the Power Automate application to see approval history. They want to have clear overview right away. And that’s exactly the reason to use this solution. It doesn’t add much complexity to the approval flow, but the benefits I see are huge.

Just keep in mind that the solution above doesn’t describe Approval process implementation, it is only an extension to an Approval process. And be careful about infinite trigger loop with ‘on update’ triggers.


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.

Add a Comment

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