Introduction
I recently had to implement a workflow where changes for the tax exempt no. on the accounts payable record has to be approved by a second person.
The new requirement (for me at least) was:
If only one user needs to approve the workflow (single approver), and the workflow is assigned to multiple users to approve it, how to prevent that all users jump on the workflow at the same time to approve it?
There should be some kind of process that when someone starts working on the approval, the others should know that.
Through some trial and error I gained some experience which I would like to share with you. I am not claiming its the best or only way to meet the requirements.
I hope I can give you some insights on possibilities you can use to meet the requirements for your business cases.
Let me explain some core requirements.
- The tax exempt no. must not be changed, unless a second person approves the change
- There are multiple people who can approve the workflow, but only 1 needs to approve it (single approver)
- If one person starts looking into the submitted changed, others need to be aware of it in order to avoid multiple people working on the same task.
ad 1:
This is fulfilled with the Workflow engine in F&O. Once the user submits the changes, a work item is created to be approved\rejected. The changes are effective when the workflow is approved.
There are some fields you can define for approvement, it doesnt have to be the tax exempt no.
ad 2:
This also defined in the workflow engine. You can define if you want a single approver, if all need to approved that are assigned to the workflow or a defined percentage, f.e. 60% of the people assigned to the workflow need to approve it. In my case, it was only a single approver necessary.
ad 3:
Now this was a bit tricky at the beginning but fairly easy to implement.
The idea is the following.
- all approvers have access to the same outlook mailbox.
- an email is sent to this shared mailbox when an approvement is necessary.
- when someone picks an email (workflow), he\she marks it with an outlook category, so the others know the work item is being processed.
There are some things I wont explain in order to focus on the core solution, so I assume you are either familiar with them or you make yourself familiar with it. In case you need help, drop a comment and I ll post some resources.
- how the F&O Workflow engine works
- how to establish a dataverse connection with F&O
Design decisions
Before I start showing how I implemented it in detail and what you need to look at, let me explain some core decisions
Why Power automate (PA) is necessary?
The workflow engine in F&O allows you to send out emails in various statuses. F.e., to people who needs to approve something or to the workflow originator, so that he\she knows the workflow is approved\rejected. However, you can assign a workflow only to one or more user(s), you cant just sent an email to a define mailbox.
That means, the users who are assigned to a work item receive an email and these users are able to approve\reject the workflow.
This is where PA comes into play.
The flow itself is quite simple:
1.: When a work item is assigned to a user
2.: This is necessary to process some information
3.: This is where I send out an email to the shared mailbox. Because I implemented also an approval for vendor bank changes (IBAN), I decided to add it to the flow. The switch decides between the two workflows. I wont go into detail regarding the two workflows, just wanted to explain the flow itself.
Why dataverse connector and not FinOps connector?
Well, I went for a business event first. However, I realized quite fast, that I have to define the workflow workitem in the flow (1), which correspondents to the workflow in F&O (2).
In my case, I had to implement 2 workflows, in 6 companies. that means I would need 6 business events (=flows) for each workflow, ending up in 12 flows.
Maintaining these flows made me think of another solution, so I opted for the dataverse connector.
You may have only 1 workflow and 1 company to implement a solution. However, think about extensions in the future, so you may create a good foundation now.
Core steps of implementation
Now, I ll explain the core steps of my implementation and what to look at. I will not explain every single step, so being familiar with PA flows and D365FO Workflows is a precondition for the understanding.
Using a service user as an approver
In my workflow I assigned a user group to be able to approve\reject the workflow.
As mentioned before, there are multiple people who can approve the workflow, so we dont need to worry about that all of them are on vacation at the same time or absent in generally, so no one can approve the workflows.
I assigned our service user to the user group as well, which I will explain shortly.
In my PA flow, we use the table name Work items (mserp) that gives us all the necessary information about the work item.
So, when a user submits the workflow, F&O assigns the workflow to my user group, which consists of 3 people (users) + my service user.
The dataverse connector above is triggered 4 times in this case, because for each user, 1 row in dataverse is created (added) which triggers 1 flow. As you can imagine, I dont want 4 emails to be sent for the same approval (workflow).
In order to solve this, I added a trigger condition, where the flow is only triggered when a work item is added to my service user. So, when a workflow is submitted, 4 users can approve the workflow, but only 1 email is being sent to the shared mailbox.
The other conditions I set to limit the flow for certain companies and also workflows, but thats a different story.
Parsing workflow instructions
When you send out an email to the users assigned to approve the workflow, you want to add some work item instructions, like link to web, last comment and maybe some other information.
In the workflow engine, you would write it in a nice way.
From the dataverse connector, you receive this information as ONE STRING!
Now the question is: How do I receive the information I want to pass in the email in a way I can structure well?
In the F&O workflow, you need to design the workflow instructions as the following.
For each placeholder, you need one line, all lines seperated by a "," (comma)
HINT:
Be aware that the work item instructions need to be set up in the same language as the language of the service user language.
In the flow you do the following:
1.: create a Parse JSON step
2.: pick the mserp_description from the previous parse json
3.: you can c&p the text from the above work item instructions.
As a result, you receive a nice JSON, where you can put in your email the status, workflow link and other information nicely and readable for the users.
Now I can pick up the fields and put them in the email I send to the mailbox.
Excursus - How to display the LinkToWeb as a text
The following has nothing to do with the main topic, however, if you are implementing something similar you may need to know it.
If you use the "LinkToWeb" and put it in your email, the email will display the link as a link which is a quite long string.
If you want the link to be display as a text, which the hyperlink in the background of course you need a compose step.
You can copy and paste the following to your compose step:
concat('<a href="', DYNAMIC CONTENT OF THE STEP IN THE SCREENSHOT BELOW, '">THE TEXT BEING DISPLAYED IN THE EMAIL</a>')
Results
When a work item is assigned to the service user an email is being sent out to a shared mailbox.
In the shared mailbox the email looks as the following (sorry for the language in German, but you get the idea)
ad1: The link to web
ad 2: some general information about the record
The first user that wants to process the submitted approval marks the email in outlook as "in process", so the other approvers dont touch that email as someone of them is checking the workflow.
Because the approvers have also assigned the work item in the D365FO workflow, they are able to approve, reject or delegate the workflow.
Final thoughts
The workflow engine is a great tool that prevents some actions without an approval.
However, the possibilities of designing emails and also functionalities is quite limited. For me, the combination of Power automate and the dataverse connector is the way to go.
Thanks for reading so far!
If you are interested in my other blogs