{"id":110980,"date":"2018-07-12T06:59:48","date_gmt":"2018-07-12T13:59:48","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/approvals-by-majority\/"},"modified":"2018-07-12T06:59:48","modified_gmt":"2018-07-12T13:59:48","slug":"approvals-by-majority","status":"publish","type":"power-automate","link":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/approvals-by-majority\/","title":{"rendered":"Advanced | Flow of The Week: Creating Your Own Workplace Democracy With The Power of Approvals!"},"content":{"rendered":"
Sometimes it gets difficult to make decisions in the work place. Whether it be important documents that need review or even more essential rulings like deciding a time to get that sweet Starbucks, Flow has your back with Approvals. Right now, you can do a lot with our two current types of Approvals:<\/p>\n
But what if that\u2019s not enough? I mean with \u201canyone can approve\u201d you don\u2019t want to give anyone all that power<\/em>. On the other hand, with \u201call must approve\u201d, you\u2019re having flashbacks about last week when everyone wanted sushi except Jeff and he had to ruin it with a reject on your well-crafted approval. We demand democracy!<\/p>\n Or\u2026 maybe you just want to take your group decision making to the next level?<\/p>\n We\u2019ve had lots of customers interested in more complex types of approvals such a quorums and multi-stage approvals. I assure you it\u2019s on our minds too! Eventually we\u2019ll have simpler built in approval types, but until then I\u2019ll show you a way you can create your own little checks and balances system for your new team agreement accords<\/em>.<\/p>\n <\/p>\n I know it looks like a lot but really, it consists of two main approval steps to mimic a multi-stage approval: Q: So how do we accomplish this?<\/p>\n A: Triggered<\/u><\/p>\n <\/p>\n Now to the real stuff.<\/p>\n You can start out with any trigger you want, typically something involving an item or file works well for approvals.<\/p>\n Stage 1: Let\u2019s get congress to agree on something<\/u><\/p>\n Since a \u201cmajority must approve\u201d approval doesn\u2019t exist we are going to\u00a0create our own using a technique that can be modified to do all kinds of approvals.<\/p>\n The basic idea behind this is that we have our list of approvers that we want to send this \u201cmajority must approve\u201d approval to, but instead of sending one approval assigned to everyone, we can break it up and assign each person a single approval in parallel, collect all the responses and then decide what to make of them.<\/p>\n \n<\/p>\n Bonus:<\/strong> If you would like to know how to get a dynamic list of approvers for something like a SharePoint item check out this earlier flow of the week about sending parallel approval requests for a dynamic set of approvers<\/a>. Next, we need a way to keep track of our responses. I found the easiest way to keep track of the responses by using two separate arrays:<\/p>\n The reasons why this approach is great is because we can use:<\/p>\n <\/p>\n Now that we have our approvers and can keep track of responses we can add a \u201cApply to each\u201d on the list of approvers and create an approval and record the response in the proper list.<\/p>\n <\/p>\n It\u2019s very important not to forget to make your \u201cApple to each\u201d execute in parallel by going to options and enabling \u201cConcurrency control\u201d.<\/p>\n <\/p>\n Finally, to complete this approval stage now that we\u2019ve recorded our responses, we can simply just compare the lengths of the array using expressions and a condition card:<\/p>\n <\/p>\n <\/p>\n So now to complete the Executive<\/u><\/em> Approval we need our stage 2 approval if the result of the first stage ended up being a majority of approve.<\/p>\n Note: In the case of reject you could send an email notification listing out the results as a html table. (That\u2019s what I did, this is where concat comes in handy with more variables)<\/p>\n Approval Stage 2: Electric Boogaloo<\/u><\/p>\n This approval is just a regular approval who is assigned to an Executive<\/u><\/em> approver of your choosing. Someone who you can really depend on like Tom. Tom is really dependable\u2026<\/p>\n <\/p>\n You can just hook this approval up to another conditional and now the multi-stage approval is essentially done! Our Executive<\/u><\/em> approver can now make decisions; Simple right? Well\u2026<\/p>\n Q: How can a Flow certified public figure such as an Executive<\/u><\/em> approver make a good<\/em> decision without any context?<\/p>\n A: Now we don\u2019t just need to store whether someone approves or rejects the stage 1 approval, we also want to know who it was and their comments, which can be stored as JSON in the arrays. We can go back and edit our append variable actions to be something like:<\/p>\n <\/p>\n In order to create a pretty markdown table using our newly stored information we have to add logic to convert the responses to markdown. First, we\u2019ll initialize another variable to keep track of the converted markdown since we can have a dynamic number of responses:<\/p>\n <\/p>\n (You can read up on approval details markdown capabilities here<\/a>)<\/p>\n To finish the conversion, we can do a \u201cApply to each\u201d on the union of our two response arrays to make a single one after we get all the responses. Inside the loop we can parse the JSON objects we added and use the values in a \u201cAppend to variable\u201d action to convert the responses to markdown table rows to our variable like so:<\/p>\n <\/p>\n Finally, we can just use the markdown table variable we created as part of the approval details in the Stage 2 approval. The markdown we added should look like this once the flow is working as intended:<\/p>\n <\/p>\n That should finish out the Executive<\/u><\/em> Approval! Everything else I added to my example flow is fluff such as adding a markdown list of all the approvers to each individual approval in stage 1. Now you are ready to impress all your coworkers with your consitutional rulings!<\/p>\n Bonus<\/strong>: Instead of initializing each variable in an individual action because they can quickly bloat the flow, you could create a single JSON object that represents the state to store every variable. You can then edit the properties of the object to update it.<\/p>\n I hope everyone enjoyed this and I\u2019m interested to hear what other ideas people have building off of this! Leave a Comment Below!<\/p>\n","protected":false},"excerpt":{"rendered":" For this Flow of the Week learn from one of the Microsoft Flow Software engineers, Taylor Cambre as he teaches you how to do APPROVALS BY MAJORITY which is not a native feature in Flow but something that is OFTEN asked for!
\nIntroducing: The Executive<\/u><\/em> Approval. Pretty fancy sounding\u2026 because it is. At least, that\u2019s what your local representative would say.<\/p>\n\n
The magic of bureaucracy of course<\/s> Step by step.<\/p>\n
\nFor the sake of this tutorial I just initialized an array with a list of emails to assign as the approvers.<\/p>\n\n
\n
Magic<\/s> We can pass the responses we recorded from Stage 1 into the details field of the Stage 2 approval. The details field for approval accepts markdown now so we can make the results look pretty.<\/p>\n\n\n
\n \u00a0<\/td>\n<\/tr>\n \n \u00a0<\/td>\n \u00a0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\nCome and check out his technique, learn a new skill and leave him a comment or question!<\/p>\n","protected":false},"author":356,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","power-automate-category":[2590,2836],"power-automate-tag":[2441,2573,2591,2599],"coauthors":[2936],"class_list":["post-110980","power-automate","type-power-automate","status-publish","hentry","power-automate-category-flow-of-the-week","power-automate-category-walkthroughs","power-automate-tag-advanced","power-automate-tag-engineer","power-automate-tag-flow-of-the-week","power-automate-tag-fotw"],"yoast_head":"\n