Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
Menu

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

Posted on October 28, 2020May 18, 2021 by Tom

“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.

4 thoughts on “Display approval history in a simple, user friendly way via Power Automate”

  1. Tina says:
    March 22, 2022 at 9:23 pm

    I have a question about the creation of a sharepoint list based specifically on the approval flow triggered by one of the 5 users in my group that send out documents for approvals. We have 20-30 approvers, and their comments that need to be visible to upper management and for compliance reasons.

    Any help would be greatly appreciated! I’m trying to avoid the switch to opentext as we’ve finally got our sharepoint doc library with all it’s metadata organized beautifully!

    Reply
    1. Tom says:
      April 3, 2022 at 7:37 pm

      Hello Tina,
      if you don’t want to keep the history directly in a separate column in the library, you can use the solution described here: https://tomriha.com/how-to-log-approval-history-in-a-sharepoint-list-with-power-automate/

      Reply
  2. Craig Cowley says:
    May 10, 2022 at 9:49 pm

    Hi Tom,

    This is working great for me thanks. I’m thinking that it would be good to have the email addresses of the group of people that need to be assigned to the ‘Start and wait for an approval’ rather than have to add each user (I have a number of approval conditions and each conditions has a different list of people).

    I’ve created my excel file with a table containing a single column of email addresses. I’ve added an action ‘List rows present in table’. in the ‘Start and wait for an approval’, when I add the table name it gets put in an ‘Apply to each’ action.

    Will this mess up my history table?

    Thanks

    Craig

    Reply
    1. Tom says:
      May 15, 2022 at 5:30 pm

      Hello Craig,
      the ‘Apply to each’ is added automatically because the ‘List rows…’ action can return multiple rows (https://tomriha.com/stop-power-automate-flow-from-adding-apply-to-each-automatically/). If that’s what it should do – create a task for each row or it always returns just a single row then it’s fine. It’ll not mess up the history table if you always take the latest value and append the new response (don’t replace it).
      Some time ago I even wrote articles about a similar solution using SharePoint list for the configuration as I don’t like using Excel files: https://tomriha.com/build-approval-flow-for-various-number-of-approvers-in-power-automate/ and https://tomriha.com/use-configuration-lists-to-avoid-repeating-actions-in-power-automate/.

      Reply

Leave a Reply Cancel reply

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

NOW AVAILABLE:

The Ultimate Power Automate expressions cheat sheet
Spend your time thinking about what the flow should do, not how to do it!

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.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • How to create a new SharePoint list column with Power Automate flowMay 22, 2022
  • How to combine expressions in your Power Automate flowsMay 18, 2022
  • Import Planner tasks with checklists into various buckets (Power Automate)May 15, 2022
  • How to get notified when Planner task was reassigned (Power Automate)May 11, 2022
  • How to extract value from XML using Power Automate flowMay 8, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme