cancel
Showing results for 
Search instead for 
Did you mean: 

Build long-running Approval Flows

Flows make it easy to automate workflows that request approvals and act on responses to them. Currently, flow runs time-out after 30 days, causing any pending steps (like approvals) to time-out as well. While this isn’t a problem for most approvals, there are cases where responding to an approval can take longer than 30 days.

Creating long running approval flows

With approvals stored in the Common Data Service, you can now create flows that act on responses to approval requests, even after the original flow run has timed-out. To do this, we will use two flows – one to send an approval request and the other to run business logic on the outcome of the approval once responses to it have been received.

Step 1:  Build a flow that sends an approval.

Begin by adding the ‘Create an Approval’ action in your first flow . This action, in addition to sending approval requests, also creates a record in the Approval entity of the Common Data Service. This record is what enables us to run business logic based on the outcome of the approval, even after the flow run ends.

In the screenshot below, the definition of our first flow contains just two steps - one to manually trigger the flow using a flow button, and the second to create an approval. Note that once the approval is created, the flow run ends.

Flow 1 - Create an approval.jpgFlow 1: Create an approval

Step 2:  Build a flow to run business logic on the outcome of an approval

In this step, we’ll build a Flow that runs when an approval record in the Common Data Service is updated, checks the Result field of the approval (which stores the Outcome of the approval request) and executes business logic accordingly.

Begin by creating a new Flow that starts with the ‘When a record is updated’ trigger of the Common Data Service connector and set the Entity Name field to ‘Approvals’. To make sure we only run this flow when the Result field of the approval updated, select the 'msdyn_flow_approval_result' in the dropdown for the Attribute Filters Item

Flow 2 - When a record is updated trigger.jpgFlow 2: Trigger the flow when the result field of an approval record is updated

Let's say that onve the flow is triggered (i.e., an approval has been responded to and has an outcome), we want to do the following:

  1. Get the email address of the requestor
  2. Send an email notifying them of the outcome.

To get the user that requested the approval, we use the ‘Get record’ action of the Common Data Service connector, set Entity Name field to ‘Users’ and the Item identifier field to the Owner field from the list of dynamics values of the ‘When a record is updated’ trigger

Flow 2 - Get requestor information.jpgFlow 2: Get information about the requester

To send them an email that’s worded based on the outcome of the approval, we add a condition that checks if the value in the Result field is ‘Approve’ and then use the ‘Send an email’ action to craft messages for when a request is approved and rejected respectively

Flow 2 - Send an email based on approval outcome.jpgFlow 2: Send an email based on the approval outcome

Here's our complete flow definition that runs when an approval has been responded to, and sends an email to the requestor based on its outcome:

Flow 2 - Complete flow.jpgFlow 2: Flow to run business logic based on an approvals outcome

Comments

Hello @Karan_MSFT ,

From what I can tell by this Flow is that it checks the status of an approval.  It doesn't Restart the Approval Flow if it times out after 30 days.  How is the approval restarted?

Thank you in advance.

I don't see how this helps with approvals that run for more then 30 days.

What license level is required in order to use the common data service? I was under the impression that either a Flow plan 1 or 2, or E5 licenses was needed, to use this connector.

Meet Our Blog Authors
  • Working daily with Microsoft Cloud to deliver the needs of my company, my customers and various Microsoft communities and forums. | Office 365 | Flow | PowerShell | PowerApps | SharePoint |
  • Co-founder of https://plumsail.com, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • Solution Architect with Slalom, and organizer of the Boston Office 365 User Group, and long term SharePoint/Office 365 veteren. Find more at http://www.davidlozzi.com. Follow @DavidLozzi
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Daniel is a Business Productivity Consultant & Microsoft Business Solutions MVP who is very enthusiastic about all things Office 365, Microsoft Flow, PowerApps, Azure & SharePoint (Online). Since the preview, Daniel has been working with Microsoft Flow and later on with Microsoft PowerApps. That led to him being awarded an MVP Award for Business Solutions. He loves to blog, present and evangelize about improving productivity in the modern workspace with these amazing tools!
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc ( https://triad.co.uk)
>