cancel
Showing results for 
Search instead for 
Did you mean: 

Microsoft Power Automate: Multi-Level Approvals integrate with Microsoft Dynamic 365 CRM

Microsoft Power Automate: Multi-Level Approvals integrate with Microsoft Dynamic 365 CRM

I am writing this article to demonstrate Microsoft Power Automate is a very dynamic and vibrant component that automates more complex processes just by configuring the templates with 0% code. The idea is to Create generic Approval flow using Microsoft Power Automate which is capable to handle multi-level approval process like level 1 of approval or level 3 of approval or level 5 of approval and so on. Most interesting part of this article is user can configure Approval Medium. That is When user select Approval Medium field option to Microsoft Outlook then Microsoft Power Automate route the approval process via Microsoft Outlook. Similarly, if user select Approval Medium field option as Microsoft Teams then Microsoft Power Automate route the approval process via Microsoft Teams.

To achieve the above cited use case, I have integrated Microsoft Dynamic 365 CRM and Microsoft Power Automate to do wonders!

Working principle of Approval Process:

  1. Configure Approval Memo details for multi-level approval (like Approver email id, Approval Medium, Approval Level etc.) against quote in Microsoft Dynamic 365 CRM.
  2. Select “Submit discount for an approval” options appear in the flyout menu in Quote record.
  3. Microsoft Power Automate get triggered and retrieves all configured Approval Memo details records against quote and processes it one by one by sending the discount details via Microsoft Outlook or Microsoft Teams for an approval.

Microsoft Dynamic 365 CRM:

Approval Memo Details Entity:

I have introduced new custom entity named as Approval Memo Details which contains essential fields like approver email id, approval level, approval medium, discount amount and total amount etc.

Slide1.jpg

Approved Date: When Approver approved  our request, immediately child flow will capture the responded date and update the same in the approved date field.

Rejected Date: When Approver rejected the request, immediately child flow will capture the responded date and update it in the rejected date field.

Comments: Approver comment is captured and updated in the comment field.

Slide3.jpg

Approval Status:  

  • Approval status field is set to pending when approval memo details record is created.
  • Approval status field is set to in progress when flow takes approval memo details record for process.
  • Approval status field is set to approved when approver approves our request.
  • Approval status field is set to rejected when approver rejects our request.

Slide4.jpg

Approval medium: based on the approval medium field value (Microsoft Outlook -1 and Microsoft Teams -2), submit for discount approval flow routes the approval request to either Microsoft Outlook or Microsoft Teams.

Approval Level: User can configure the approval level like level 1, level 2, etc. based on approval level, Approval Memo details records are sorted and processed one by one for the approval.

Slide1.jpg

Approval Memo Details Configure:

User can configure Approval Memo details records for multi levels of approval against quote in Dynamic 365 CRM. For example, I have configured three level of approval memo details records for an approval process. By entering essentially details like approval email id, approval medium, approval level etc. But Total amount, discount and markup details fields are auto populated from quote when record gets saved.

Approval Memo Details configure in action:

Configure Approval Memo Details-min.gif

Microsoft Power Automate: Submit for Discount Approval:

Step 1:

When a record is selected action is the first event in the flow. It is connected to the Common Data Service(CDS) behind the environment it is running in.

Step1.jpg

As per our scenario, discount  approval process is going to be trigger from quote entity. So, I have selected Quotes in the entity name field.

If we want to pass input to the flow then we can add an inputs. So that when flow is triggered, flow will prompt the user to enter the value in the message box. But in our case, we are not passing any input to the flow.

This action allows the power automate to be appear in the flyout menu in Microsoft Dynamic 365 CRM.

Submit for discount approval in flyout meni.jpg

Step2:

Initialize variable is added to store the response from child flow. Child flow response can either be an Approved or Rejected value.

Step2.jpg

Response variable is initialized by “Approval initiated” value.

Step3:

CDS list records action is added to retrieve all approval memo details records are configured against the quote

Step3.jpg

Step4:

Condition action is added to check the response variable is equal to “Approved” OR “Approval initiated” AND approval status field value is equal to “Pending”.

Condition action is supported to add multiple conditions. And we can even use expression like And, Or to check multiple conditions.

Approval memo details records are not processed when approval status fields value is equal to “In progress” or “Approved” or “Rejected”.

Similarly, Approval memo details records are not processed when response variable is equal to “Rejected”.

Step4.jpg

Step6:

In if yes block, I have added another condition to check the approval medium field value (Microsoft Outlook = 1 and Microsoft Teams = 2).

Step5.jpg

If approval medium field is set to Microsoft Outlook, then approval process is routed to Microsoft Outlook channel.  Else the approval process is routed to Microsoft Teams channel

Step7:

Why Child Flows?

If you try to build your complex logic in to a single flow, to put all actions into single flow, it can be difficult to navigate and maintain that flow.

You can use child flows to easily manage flows, avoiding flows with multiple steps. This approach is especially benefit if you to reuse tasks in multiple places in a flow or event across multiple flows.

In our use case, I have created two child flows to inject the approval process either via

  1. Approval Process via Microsoft Outlook.
  2.  Approval Process via Microsoft Teams.

Whenever quote is submitted for discount approval, Submit for Discount Approval (parent) power automate will valid the approval medium field. Based on the value, the approval process details are routed to appropriate child flow.

Approval medium condition.jpg

Step 8:

If yes block, Approval process is routed to Approval Process Via Microsoft outlook child flow. Once approver responds to our request. Immediately child flow will return the response to parent flow. Finally, the response value is stored in the response variable.

Step6.jpg

Approval process via Microsoft Outlook Channel:

If user set the approval medium field to Microsoft Outlook, then approval process is routed to Microsoft Outlook channel. 

Step_begin.jpg

When the approval medium field is set to “Microsoft Outlook” in approval memo detail record then parent flow will call Approval Process via Microsoft Outlook child flow.

Run a Child Flow.jpg

Step 1:

When a HTTP request is received action is used to receive the HTTP request with approval memo details record GUID as a parameter when parent flow calls and send back a response to parent flow as well.

Step1.jpg

Step2:

Before sending an approval request email to user, the flow will update approval status to “In progress” to indicate that the approval memo detail record is under process

Step2.jpg

Step3:

Add the “Start and wait for an approval” action and select “Approve/Reject-First to respond” for approval type.

Step3.jpg

Approval type: When a flow with Create an Approval action is configured with Approve/ Reject – First to respond, it waits until it’s assigned to approve or assigned to reject the approval request.

Title: Discount Approval.

Assigned To: Approver email id is assigned.

Details: discount details that you want sent to the approval.

Step4:

To evaluate the user response is equal to Approve! then we need to add a “condition” to handle the response from the approval.

Step4.jpg

On the condition card, select an empty area in box on the left. The dynamic content list opens. Select the Outcome parameter to add it to the box.

In the box in the middle of the condition card, select is equal to

In the box on the right, enter the “Approve” text which is mentioned in the approval type.

Step5:

If yes block:

If outcome is equal to “Approve” then add update a record action to update essential field in that approval memo record.

Step7.jpg

Select Approval Memo Details as entity name. then set the record identifier of the approval memo details to update that record

 Scroll down to the approval status field, select the “Approved” option.

For Approved Date field, select it and fill it with the “Reponses Response Date” that you find in the dynamic content pane.

Similarly, for comments field, select it and fill it with the “Responses Comments” that you find in the dynamic content pane.

Send Back Response to Parent Flow: We need to send back response to parent flow. In this case we can use Response action.

Step8.jpg

We need to decide what response code we want to return. This will differ based on where you use this. For example, if we use this response action in case of some error, then we can return 500 0r 404 if something was not found.

In our case, I’m returning 200 OK and “Approved” text of my message and sending back to parent flow.

If no block:

Similarly, if outcome is equal to “Reject” then add update a record action to update essential field in that approval memo record. Select Approval Memo Details as entity name. then set the record identifier of the approval memo details to update that record. Scroll down to the approval status field, select the “Rejected” option.

In Rejected Date field, select it and fill it with the “Reponses Response Date” that you find in the dynamic content pane.

Similarly, for comments field, select it and fill it with the “Responses Comments” that you find in the dynamic content pane.

Else Step9.jpg

Send Back Response to Parent Flow:

I’m returning 200 OK and “Rejected” text of my message and sending back to parent flow.

Else Step10.jpg

In if no block, Approval process is routed to Approval Process Via Microsoft Teams child flow. Similarly, when approver responds to our request. Immediately child flow will return the response to parent flow and the response value is stored in the response variable.

Step7.jpg

Approval process via Microsoft Teams Channel:

If user set the approval medium field to Microsoft Teams, then approval process is routed to Microsoft Outlook channel. 

Approval Medium - Microsoft Teams.jpg

When the approval medium field is set to “Microsoft Teams” in approval memo detail record then parent flow will call Approval Process via Microsoft Teams child flow.

Run a child Flow.jpg

Step1:

When a HTTP request is received action is used to receive the HTTP request with approval memo details record GUID as an input.

Step1.jpg

Step2:

Add Update a record action to update the approval status field to “In progress”.

Step2.jpg

Step3:

We are going to create approval content like title, assigned to, details etc. So, I have chosen the Create an Approval template and configure required information.

Before continuing to configure essential information. Let’s know about the Create an approval template.

Create an approval card is a template for the approval request that’s sent to approver. Configure it in a way that’s useful for your approver.

Most importantly Create an approval actions creates an adaptive card based on configuration information.

Step3.jpg

Approval type: When a flow with Create an Approval action is configured with Approve/ Reject – First to respond, it waits until it’s assigned to approve or assigned to rejects the approval request.

Title: Discount Approval

Assigned To: Approver email id is assigned.

Details: discount details that you want sent to the approval.

Step4:

Approval Medium field is set to Microsoft Teams option. So, I have chosen “Post your own adaptive card as the Flow bot to a user” Microsoft Teams connector. This connector directs the adaptive card to the concerned member.

Step4.jpg

Recipient: Approver email id is assigned.

Message: we have passed adaptive card which is created in the previous step.

Step5:

Approver receives adaptive card approval request in Microsoft Teams. Meanwhile the flow needs to wait until approver responds to our request. The Response can be either approved or rejected. So, I have used Wait for an Approval template which halts the flow until approver responds to our request.

Step5.jpg

Approval ID: I have added dynamic content like Approval ID which gives the ID of the approval.

Step6:

To evaluate the user response is equal to Approve then we need to add a “condition” to handle the response from the approval.

Step6.jpg

Step7:

If yes block:

If outcome is equal to “Approve” then add update a record action to update essential field in that approval memo record.

Step7.jpg

Send Back Response to Parent Flow:

We need to send back response to parent flow. In this case we can use Response action.

Step8.jpg

In our case, I’m returning 200 OK and “Approved” text of my message and sending back to parent flow.

If no block:

Similarly, if outcome is equal to “Reject” then add update a record action to update essential field in that approval memo record.

Else Step9.jpg

Send Back Response to Parent Flow:

I’m returning 200 OK and “Rejected” text of my message and sending back to parent flow.

Else Step10.jpg

The above cited process is carried out for all the approval memo details records which is configured for an approval against the quote.

Discount Approved scenario in action:

Discount approved scenario-min.gif

Discount Rejected scenario in action:

Rejected Scenario.gif

Perhaps this article will also give you some inspiration on other ways to make use of Power Automate. 

 

Meet Our Blog Authors
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • SharePoint, Microsoft 365 and Power Platform Developer | Contributor on SharePoint StackExchange
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/