{"id":1354,"date":"2021-08-05T15:49:15","date_gmt":"2021-08-05T21:49:15","guid":{"rendered":"http:\/\/www.idubbs.com\/blog\/?p=1354"},"modified":"2021-08-05T15:49:15","modified_gmt":"2021-08-05T21:49:15","slug":"modern-sharepoint-power-automate-approval-with-select-user-auto-approve","status":"publish","type":"post","link":"https:\/\/www.idubbs.com\/blog\/2021\/modern-sharepoint-power-automate-approval-with-select-user-auto-approve\/","title":{"rendered":"Modern SharePoint + Power Automate Approval with Select User Auto-Approve"},"content":{"rendered":"<h2>Background <\/h2>\n<p>I\u2019m still a Power Automate newb. Lots of you have been working with these for years now. I\u2019m legit curious what silly things I\u2019m doing, what other approach I should be taking, what best practices to integrate, etc. <\/p>\n<p>So let me have it\u2026 in the comments here, in Twitter, whatever. I\u2019m waiting. <\/p>\n<h2>Overview<\/h2>\n<p>Power Automate backed approval flows for a SharePoint intranet site on the Site Pages library. Pretty slick and polished as a replacement for SharePoint workflows and nice template to look at for Automate newbs. Kudos Microsoft folks. <\/p>\n<p>Now, however, I\u2019d like to have approvals on my site, but also have them bypassed for certain users \u2013 folks that own the site, do the majority of content generation, etc. I still want the process in place because I have other content contributors that I still want to manage. <\/p>\n<p>So, we have an out of the box page approval flow that I want to tweak. <\/p>\n<p>It sounds potentially easy, but we all know better. There will be some pain. And there is. But we can work with it. <\/p>\n<h2>What I did<\/h2>\n<p>The out of box page approval flow looks as follows: <br \/><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/OOB-Approval-Flow.png\"><img loading=\"lazy\" decoding=\"async\" width=\"442\" height=\"174\" title=\"OOB Approval Flow\" style=\"display: inline; background-image: none;\" alt=\"OOB Approval Flow\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/OOB-Approval-Flow_thumb.png\" border=\"0\"><\/a><\/p>\n<p>With the exception of a few new variables I added, all changes were limited to the \u201cScope 2\u201d step. When I was finished, the top level view looked like this: <br \/>(Yes, I should be consistent with my naming \u2013 I\u2019ll clean that up) <\/p>\n<p><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Final-Approval-Flow.png\"><img loading=\"lazy\" decoding=\"async\" width=\"444\" height=\"420\" title=\"Final Approval Flow\" style=\"display: inline; background-image: none;\" alt=\"Final Approval Flow\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Final-Approval-Flow_thumb.png\" border=\"0\"><\/a><\/p>\n<p>I\u2019ll walk through the variables shown above as we go. <\/p>\n<h3>Who Gets Auto-Approved<\/h3>\n<p>This is a topic that could be debated in terms of the best way to manage the list or folks that get auto-approved. Should you use a list, an Azure Group, a SharePoint Group, or something else? For simplicity\u2019s sake, I\u2019m going with a list. It\u2019s the easiest to maintain visibility and control at the team level without needing to work with a security team every time we need to change a group. I\u2019m also pretty confident that Automate can get to the data I need in a list. I\u2019m not yet sure about the other approaches. Obviously a decision like this may vary org to org. For this example, we\u2019re using a list. <\/p>\n<p>I created a SharePoint list and called it \u201cAutoApproveNews\u201d. Yep, I\u2019m old school and don\u2019t like spaces in my list names. I\u2019m not messing with the Title field right now, so just left it alone and required. It\u2019ll need to be filled with rubbish for now. The only column I added to the list was AutoApproved as a Person or Group field displaying the Name. Yes, the name might not be unique\u2026 so something to look at later to seal the process up a bit more. Using the email address is probably a nicer, more unique, approach but I haven\u2019t tried that variation yet. <\/p>\n<p>I didn\u2019t do anything special with permissions for the list while validating this concept, but there are a few ground rules you\u2019d likely want to follow. <\/p>\n<ul>\n<li>Make sure whatever connection you\u2019re using to SharePoint from Automate has access to the list. <\/li>\n<li>Lock down the list to the folks that manage content so random users can\u2019t just add themselves. <\/li>\n<li>I also found it useful to remove the list from navigation. Don\u2019t like cluttering things up unnecessarily. <\/li>\n<\/ul>\n<h3>First note on variables<\/h3>\n<p>The approach I\u2019m using is that I\u2019m going to get the name of the person submitting the news article, iterate through my list of folks that get auto-approved, and trip a flag that indicates I found a match. <\/p>\n<p>So with that, AutoApproveFlag is created and set to false. <\/p>\n<p>NewsSubmitter is set to the name of the person that added the new news article or page from the \u201cFor a selected item\u201d step. <br \/><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Submit-Variable.png\"><img loading=\"lazy\" decoding=\"async\" width=\"485\" height=\"156\" title=\"Submit Variable\" style=\"display: inline; background-image: none;\" alt=\"Submit Variable\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Submit-Variable_thumb.png\" border=\"0\"><\/a><\/p>\n<p>The other variables are used in the text of the email, so you can fill in whatever fits for you. Here\u2019s what I did for now: <br \/><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Variable-Initialize.png\"><img loading=\"lazy\" decoding=\"async\" width=\"487\" height=\"326\" title=\"Variable Initialize\" style=\"display: inline; background-image: none;\" alt=\"Variable Initialize\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Variable-Initialize_thumb.png\" border=\"0\"><\/a><\/p>\n<p>You\u2019ll see where they fit in down below. <\/p>\n<h3>New Steps<\/h3>\n<p>Using as much of the default flow as possible. <\/p>\n<ol>\n<li>After the \u201cSet content approval status \u2013 Pending\u201d add a step to \u201cget items from\u201d a SharePoint list and point it to the AutoApprovedNews list we just created. <\/li>\n<li>Add a \u201cApply to each\u201d step to iterate through the SharePoint list data. <br \/>Add a condition where if a match (comparing the AutoApproved field to the NewsSubmitter variable) is found, set the AutoApproveFlag variable to true. <\/li>\n<li>Add a Condition step. Test for the value of variable AutoApproveFlag \u2013 if not true (no matches found), then start the flow approval. I added the condition step and then dragged the existing \u201cStart an approval\u201d step into the No condition.\n<p>Note: Because there will be some conditions where the Approval doesn\u2019t exist, I need to change some of the email steps later in the flow because they use properties of the Approval in their email content \u2013 hence the other two variables that were created: strApprover and strComment. (I should be consistent with variable naming, started thinking about that after I was underway \u2013 cleanup for later)<\/p>\n<\/li>\n<li>The default flow has a Condition step that waits for the approval response. I didn\u2019t see a way to change the condition the way I wanted, so I created a new Condition step to check for an approval response OR check if the AutoApprovedFlag variable was set to true.\n<p>Note: DO NOT delete the original Condition step until after #5 below and you\u2019ve moved\/copied the steps from the original to the replacement. <\/p>\n<p>Original: <br \/><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Original-approval.png\"><img loading=\"lazy\" decoding=\"async\" width=\"439\" height=\"106\" title=\"Original approval\" style=\"display: inline; background-image: none;\" alt=\"Original approval\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Original-approval_thumb.png\" border=\"0\"><\/a><\/p>\n<p>Replacement: <br \/><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/New-Approval.png\"><img loading=\"lazy\" decoding=\"async\" width=\"449\" height=\"206\" title=\"New Approval\" style=\"display: inline; background-image: none;\" alt=\"New Approval\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/New-Approval_thumb.png\" border=\"0\"><\/a><\/p>\n<\/li>\n<li>Move or copy the steps in the yes and no conditions to the new condition step (#4 above). I was able to drag and drop some, but also needed to use the preview functionality of copying steps to the clipboard and then used the \u201cAdd an action\u201d feature to add from clipboard. <\/li>\n<li>Now you can delete the original Condition you just copied the steps from.<\/li>\n<li>In order to clean up the emails sent later, I needed to replace Approval properties in the email content with variables that would work both when approvals were automatic and manual. In order to make these work, I needed to add a Condition step and Set Variable steps.\n<p>With new Condition rules, moved steps, and an additional Condition step, the flow looks like this: <br \/><img loading=\"lazy\" decoding=\"async\" width=\"789\" height=\"429\" title=\"After Moves\" style=\"display: inline; background-image: none;\" alt=\"After Moves\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/After-Moves_thumb.png\" border=\"0\"><\/p>\n<p>Setting the variables as follows: <br \/><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Set-Approval-Vars.png\"><img loading=\"lazy\" decoding=\"async\" width=\"515\" height=\"321\" title=\"Set Approval Vars\" style=\"display: inline; background-image: none;\" alt=\"Set Approval Vars\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Set-Approval-Vars_thumb.png\" border=\"0\"><\/a><\/p>\n<\/li>\n<li>Finally, we need to update the email content to replace the Approval properties with variables. Only the \u201cSend email notification\u201d steps (both \u201cYes\u201d and \u201cNo\u201d outcomes) under the scheduling condition (\u201cCheck if content has been schedule or not\u201d) need to be updated.\n<p>These are the ones you\u2019re changing: <br \/><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Which-email-steps.png\"><img loading=\"lazy\" decoding=\"async\" width=\"759\" height=\"363\" title=\"Which email steps\" style=\"display: inline; background-image: none;\" alt=\"Which email steps\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Which-email-steps_thumb.png\" border=\"0\"><\/a><\/p>\n<p>From this: <br \/><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/TextBefore.png\"><img loading=\"lazy\" decoding=\"async\" width=\"322\" height=\"176\" title=\"TextBefore\" style=\"display: inline; background-image: none;\" alt=\"TextBefore\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/TextBefore_thumb.png\" border=\"0\"><\/a><\/p>\n<p>To this: <br \/><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/TextVariables.png\"><img loading=\"lazy\" decoding=\"async\" width=\"324\" height=\"160\" title=\"TextVariables\" style=\"display: inline; background-image: none;\" alt=\"TextVariables\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/TextVariables_thumb.png\" border=\"0\"><\/a><\/p>\n<\/li>\n<li>After we\u2019re all done, Scope 2 looks like this: <br \/><a href=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Scope2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"457\" height=\"471\" title=\"Scope2\" style=\"display: inline; background-image: none;\" alt=\"Scope2\" src=\"http:\/\/www.idubbs.com\/blog\/wp-content\/uploads\/2021\/08\/Scope2_thumb.png\" border=\"0\"><\/a><\/li>\n<\/ol>\n<p>I think that\u2019s everything. I\u2019ll update if I find additional details. <\/p>\n<h2>Recap, Summary<\/h2>\n<p>It works. What am I missing? What should I have done different? <\/p>\n<p>Bring it!! <\/p>\n<h2>References and stuff<\/h2>\n<p>Thanks to Mark Rackley for a few pointers\u2026 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Background I\u2019m still a Power Automate newb. Lots of you have been working with these for years now. I\u2019m legit curious what silly things I\u2019m doing, what other approach I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[191,187,21],"tags":[189],"class_list":["post-1354","post","type-post","status-publish","format-standard","hentry","category-power-automate","category-power-platform","category-sharepoint-online","tag-approvals"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgWQ1-lQ","jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/posts\/1354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/comments?post=1354"}],"version-history":[{"count":1,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/posts\/1354\/revisions"}],"predecessor-version":[{"id":1355,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/posts\/1354\/revisions\/1355"}],"wp:attachment":[{"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/media?parent=1354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/categories?post=1354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.idubbs.com\/blog\/wp-json\/wp\/v2\/tags?post=1354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}