By: Scott Brown, Ting Ma, & Ruben Lie
Typical approval workflows in Microsoft Dynamics NAV trigger a sequence of individual approvers. Alternatively, you can use an approval group to allow the required number of approvers from the group to grant approval. Our client ran into a roadblock when attempting to build a workflow that provided a sequence of approval where each level could be one of a select group.
As a representative scenario, let’s look at a process where an item needs to go through three levels of approval, but at each level the approval can come from either of two users.
When sending an item for approval:
- Two level 1 users have approval requests generated (either level 1 user can approve)
- Following approval, two users at level 2 have approval requests created (either level 2 user can approve)
- Subsequent to level 2 approval, two users at level 3 have approval requests produced
- When either level 3 user approves, the item restriction releases and the approval process is complete
The steps required to achieve the desired result are as follows (note: the break down for each step is below):
- Define a Workflow Group
- Enhance the Template Workflow
- Assign the Workflow Group to the Workflow
- Control the Workflow behavior (based upon the sequence number of each approval provided)
- Keep the Workflow active until granting final approval
- Properly close the Workflow once the final required approval (a level 3 approval) is provided
Step 1: Defining a Workflow Group
To provide a list of approvers, and appropriate sequence (or approval level), a Workflow User Group is required. The example below (where WORK# represents what would be the specific NAV user) provides what is required for this scenario. There are two users identified at each Sequence, and in total, there are three levels.
Step 2: Enhance the Template Workflow
Microsoft Dynamics NAV provides a template for a typical approval workflow. Using this as a starting point, the rows highlighted in green (see the image below) can remain unchanged.
Step 3: Assign the Workflow Group to the Workflow
In order for the approval requests to route to the users identified in the defined Workflow User Group, the options need updating in the “Create an approval…” response associated with the “Approval of an item…” event.
Step 4: Control the Workflow behavior (based upon the sequence number of each approval provided)
In this workflow, we list four conditions after approval of a request (the conditions are the combination of Sequence No. and Pending Approvals). By using the combination, the workflow can properly define the response at each level of approval. The Sequence No. reflects the level in the user group,which issues approval (see Defining a Workflow Group, above).
Sequence No.: 1, Pending Approvals>4: Please note the total number of approvers in the Workflow User Group is 6. When met, this condition means only the first user at Level 1 has approved the request. The response is to send two approval request for users at level 2.
Sequence No.: 1, Pending Approvals<5: When this condition is met, it means the 2nd user at Level 1 approved the request. At this time, the first user already sent the approval request to level 2, so an additional approval request is not needed. In this example, we have provided a message to the user indicating the granting of level 1 approval. This is not required for the workflow to function properly, but does provide useful information to the approver.
Note: Under this condition, it is important to prevent activating further approvals, as doing so would trigger the next inactive approval level. Since the level 2 requests are active after the first level 1 approval is provided, a new approval request would be sent to level 3. This would create active level 3 approvals prior to any approval at level 2. We do not want this, as level 3 triggers should only happen following the provision of level 2 approval.
Sequence No.: 2: When this condition is met, it means that one of the level 2 users approved the request. The response is to send the approval request for users at level 3. In this case, the workflow user group only contains three levels, so no additional requests remain to be sent if the second user at level 2 approves the request. Therefore, there is no need to define the response specifically for the number of approvals remaining at level 2, as we did for level 1.
Sequence No. : 3:
Once this condition is met, it means that one of the level 3 users approved the request. The response is to remove record restriction.
Step 5: Keep the Workflow active until granting final approval
For each conditional branch in the workflow that does not end the approval process, it is critical to direct the workflow to a next step. In this case, the next step (see highlighted text in image below) needs to point back to the end of the first event in the workflow. This keeps the workflow active and when the next event (e.g. another user approval) is triggered the workflow continues handling the event.
Step 6: Properly close the Workflow once the final required approval (a level 3 approval) is provided
Lastly, it is important to setup the workflow to close after granting the last approval. For the , an additional response called “Approve the approval request for the record.” is required. By adding the additional response, it will ensure that any unapproved entries (since only one from each level is required) will update to “approved.”
If the response is not added, then it would result in the other approver status remaining open. The workflow would effectively be in a limbo state as it would not know what steps were next, and even if the user tried to cancel the approval request, the workflow would not respond.
The workflow functionality in Microsoft Dynamics NAV (versions 2016 and newer) provides flexibility that goes well beyond the templates that are provided as starting points. We have provided an example that shows some of this flexibility, but it is only one example of what is possible.
For more information, contact us.