Multi-Approvals inside 1 Workflow - How to master Dynamics 365 Business Central Workflows

..there, I said it!

Approvals are a vital business control process, the most common area being around the approval for purchases and expenditure.

Dynamics 365 Business Central (D365BC) has a built-in approval workflow engine and can also tap into Power Automate Approvals. 

Approvals via Power Automate have a few really great positives, but this post is not about those. Here I'd like share some tips on using BC's built-in approval engine for some complex scenarios. 

For really complex approvals, Power Automate gets tricky quickly. While the build-in approval can scale stably in my experience.

To illustrate my view, here is a complex approval scenario that the BC engine handles fairly easily. 

Multi-Approval Example & How-to

Business Requirements

The Purchaser Admin (PA) will create a draft PO, which in all cases must be approved by the Project Manager (PM). Following the PM approval further approval is value based as shown below.
  • Level 1 - approval by PM up to £10k
  • Level 2 - further approval by a named Senior Manager up to £50k
  • Level 3 - further approval by a named Head of Team up to £100k
  • Level 4 - further approval by a named Director up to £250k  
  • Level 5 - further approval by the CEO for over £250k
There are multiple departments, which is held on the document as a global dimension. 

Quotes and Orders over 250k, in addition to the above logic, also need to go to a named user in the procurement team, but this is not necessary for invoices.

Workflow Solution

  • Level 1 - the Project Manager are all created as Purchasers, so the PA who could be working across multiple projects can select the appropriate project manager, i.e., they drive the initial step by selecting who to send the document to.
  • Level 2..5 - These will be managed with the standard Workflow User Groups, the department global dimension is used to help route the approvals.
  • We will create 1 workflow per department using the "Send Another Approval" approach that I explain below.

Technical Setup

Here is an example workflow:

Muti-approval for the Admin department

Line 1 - Initial Step

The initial step has the On Conditions to catch all open documents sent for approval for the Admin department (that happens to be Global Dim 2) and has these Then Responses:
  • Add record restriction 
  • Set document status Pending Approval 
  • Create an approval for the record using approver type Salesperson/Purchaser and approver limit type Direct Approver
  • Send approval request for the record and create a notification
Very much like a simple normal approval process - nothing special yet

Line 2 - Level 1 Approval

To handle the PM approval line 2 filters for docs with an amount of ..10,000.00 and uses these Then Responses
  • Remove record restriction
  • Release the document 

Line 3 - Level 2 Approval - Sending a further approval

This is the first example, within this workflow of sending another approval out. To manage this you need to tweak the Workflow Event/Response combinations. By default not all the Then responses shown below are available after the When Event "An approval request is approved"

..for example "Reopen the document"

The Then Responses for line 3 that trigger the next approval for documents with an amount of 10,000.01..50,000 are as follows
  • Approve the approval request for the record
  • Reopen the document.
  • Set document status to Pending Approval.
  • Create an approval request for the record using approver type Workflow User Group and workflow user group code ADMIN-L2.
  • Send approval request for the record and create a notification.
  • Show message "Sent for Level 2 approval (10k-50k)".
    • Next then "<The last Then Response of Line 1>"
2 tips on this line, one is a handy to know, the other is vital!
  • Handy: When setting up complex workflows, always include a simple message. Because when you are testing, it is super handy to know where things are routing. This is a huge help when debugging the config.
  • Vital: The flux capacitor for multi-approval workflows is the use of the <(Optional) Select Next Step>. This is available from the last step of the Then responses. To make multi-approvals work you need to set the next step to the last Then response of line 1.
Click the last step, then click the link, which if not set shows as "<(Optional) Select Next Step>"

This line is the 'Last Then Response' line of the 1st main workflow config line

What this does is allow the routing to evaluate all lower down steps at indent 1. If you don't remember to do this small config, things like the Cancel Approval, Delegate, Reject etc etc won't work.     

Lines 9 & 11 - Send to next approver or Release the Doc

Lines 9 and 11

These lines hold the fairly normal "send to next person" / "we are done now" logic. The On Condition of "Sequence >1" ensures they are not part of the initial approval by the PM. 

The line 9 "Send to next person" Then responses are   
  • Send approval request for the record and create a notification.
  • Show message "Sent for further approval".
    • >Next then "<the last Then Response of line 1>"
The line 11 "we are done now" Then responses are
  • Remove record restriction.
  • Release the document.
  • Show message "Fully approved".
  • Create a notification for <Sender>.
The other lines handle the different values and document types, but the principle remains the same for doing an direct approver approval followed by a workflow user group approval all inside 1 workflow!

Other departments?

This workflow once fully tested was replicated for all the departments, using import and export you can do a fairly easy find and replace on the workflow user group codes. The only manual step is the selection of the department code for line 1 on Condition. So overall it's fairly trivial to copy the config for a lot of departments.

I could have added the other departments inside this workflow, but it was faster to copy the whole workflow and gave some granularity around testing (enabling/disabling for a give single department) 

General workflow tips

Setting up and testing workflows can be a pain - always create a workflow testbed system - where you have multiple logins for all the personas in your workflow, use the edge profiles so you can easily have 5 edge browsers open / pinned to your task bar for each of the different user and quickly test a super complicated approval going to multiple accounts without actually needing to tie up anyone else.

When doing multiple approvals it is possible to create an infinite loop. Be sure to use the "Sequence No" in the On Condition to avoid this. If you do have an infinite loop event - end your session from the admin portal!

Always insist on a clear flow diagram for the approval logic - that must always be creased by the end client. This is a vitally important document for creating and testing approval flows. Also allows you to judge the time to do the work and acts as a CR trigger if anyone changes their mind on the eve of go-live for example!  

Next time

Here is another complex approval requirement! I'll share the how-to details on this one in a future post.

Another complex approval requirement that D365 BC workflows can manage, fairly easily!