Tested on:
Dynamics 365 version 9.0.2, PSA solution version 3.x, Unified Interface, Microsoft Flow
Time and Expense Entries and their approvals are an important part of Dynamics 365 Project Service Automation. A slight downside to Project Approvals is that the logic is based on a single level approval process: A user (or users) set as a Project Approver under Project Team Members approves all Time and Expense Entries related to a Project. But what if a manager’s approval is needed before a Project Approver signs off on submitted hours? To achieve this, we’re using Microsoft Flow to build a two-tier approval process.
Before I start going through the solution, I want to point out some very good Microsoft Flow posts from the community. These help you understand some of the steps in my solution and they’ll also shed some light on the differences between the D365 and CDS connectors in Flow etc. Be sure to check these out:
Out of the box functionality
The OOTB functionality for approving Time and Expense Entries is as follows:
Building a solution for two-tier Time Entry approvals
The initial approval in this solution will be based on Flow and the second, final approval, will leverage PSA’s OOTB functionality. As Actuals are created when a Time/Expense Entry is approved, meddling with the OOTB logic is inadvisable. Instead, additional logic can be built around the OOTB functionality to extend PSA’s capabilities.
Remember that this is a single example of extending Project Approvals and that approval Flows only work with internal users. There are other ways to approach this issue as well as some organizations may require an approval process that has more than two tiers.
1. Fields on Bookable Resource
The following three custom fields are added on Bookable Resource:
Vacation and Absence approvals in PSA are always approved by a manager defined under a user record (Settings -> Security -> Users). As this manager might differ from the one approving project related work, custom fields on Bookable Resource are needed.
2. Views and fields on Project Approval
Project Approval has a custom view for a manager approving entries. Some custom fields are also required so that the approval process can be properly run. Remember that first we are getting an approval by a manager, followed by PSA’s OOTB approval process by a Project Team Member set as a Project Approver. The custom fields on Project Approval are:
3. Real-time workflows for Project Approval
A real-time workflow is needed to prevent a Project Approver from approving entries that have not yet gone through the initial approval. A workflow gives an error message if the initial approval is not complete. A second workflow is used to pull values from the custom fields on Bookable Resource to Project Approval. The approval Flow has a condition that checks the values of Time Entry Type, Manager’s Email and Approved by Manager. To get the condition working, a real-time workflow updates the fields on Project Approval.
4. Time Entry approval Flow
Now that the required fields, views and real-time workflows are ready, we can build the actual approval Flow. Check out the three links I mentioned earlier if you want additional ideas around connectors, expressions and if your scenario requires several approval tiers. For this Flow the condition to fire off an approval is:
@and(equals(triggerBody()?[‘cust_approvedbymanagerc’], 832090002),
equals(triggerBody()?[‘cust_timeentrytype’], 192350000),
equals(empty(triggerBody()?[‘cust_managersemailc’]), false))
In plain English:
If Approved by Manager = Pending
AND
Time Entry Type = Work
AND
Manager’s Email contains data
–> fire off the approval process
5. Testing the Flow
Let’s test the Flow by both approving and rejecting a submitter’s Time Entries. I’m submitting Time Entries as John Doe. His manager is Jane Doe.
Approving Time Entries
Rejecting Time Entries
I hope this post helps you implement an additional layer of approvals for Time and Expense Entries in Dynamics 365 Project Service Automation. If you want to download the managed solution and the Flow, you can get them from the Those Dynamics Guys PowerApps Bank here.
Disclaimer:
This blog post reflect my personal opinions and findings unless otherwise stated