cancel
Showing results for 
Search instead for 
Did you mean: 

Two-tier Time Entry approvals in D365 PSA with the power of Flow

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:

 

  1. Microsoft Flow basics and limitations when working with Dynamics 365 by Thanura Wijesiriwardena.
  2. Microsoft Flow Approval Workflow by Senior Platform Evangelist Jon Levesque.
  3. What The Flow series by Business Applications MVP Elaiza Benitez.

 

Out of the box functionality

The OOTB functionality for approving Time and Expense Entries is as follows:

 

  • A user is set as a Project Approver on Project Team Members. That user will then be able to approve all Time and Expense Entries related to the Project.
  • A user submits Time/Expense Entries -> Journal Lines are created -> a Project Approval record is created.
  • A Project Approver approves the submitted entries -> Actuals are created.
    • If the entries are rejected, the submitter will see the related entries as “Returned” on the Time Entry entity.

 

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:

 

  • User’s Email. Value from this field will be passed to Project Approval to serve as a Requestor in an approval Flow.
  • Value from this field will be passed to Project Approval to indicate the manager who will be responsible for the initial approval stage.
  • Manager’s Email. Value from this field will be passed to Project Approval. An approval Flow will then use the value from this field on the Flow’s Assigned to

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.

 

1-bookable-resource.png

 

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:

 

  • Time Entry Type. This indicates whether an entry is for Work, Vacation or Absence. Only Work will fire off an approval Flow as in PSA. Absence and Vacation will be approved by a manager defined under a user record.
  • Submitter’s Email. Value from this field will be used in an approval Flow’s Requestor field.
  • Manager for Approval. Used to indicate the manager who will be responsible for the initial approval stage.
  • Manager’s Email. An approval Flow will use the value from this field on the Flow’s Assigned to field.
  • Approved by Manager. Values are Pending, Yes and No. Only records that have a value of Yes on this field can be approved from the ribbon’s Approve button.
  • Manager’s Comments. Comments written by a manager to an approval email will be seen on this field.

 2-project-approval-view.png

 3-project-approval-form.png

 

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.

 

manager-approval-workflow.pngPrevent entry approval before initial approval is processed.Prevent entry approval before initial approval is processed.

update-project-approval-workflow.pngUpdate Project Approval from Bookable Resource.Update Project Approval from Bookable Resource.

 

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

 

 

Steps-of-the-Time-Entry-approval-Flow.png

 

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

 

approval-process.pngThe approval process is fired off as all conditions are met.The approval process is fired off as all conditions are met. approval-email.pngJane Doe receives an email to approve John Doe’s Time Entries.Jane Doe receives an email to approve John Doe’s Time Entries.

 push-notification.pngA push notification is also sent as the Flow mobile app is installed. Time Entries can be approved either from the mobile app or from the email message.A push notification is also sent as the Flow mobile app is installed. Time Entries can be approved either from the mobile app or from the email message.

 flow-has-run-sucessfully.pngThe Flow has run successfully and the entries have been approved by the manager – Jane Doe.The Flow has run successfully and the entries have been approved by the manager – Jane Doe.

 initial-approval-processed.pngAs the entries have been approved, the field Approved by Manager has a value of Yes. Jane Doe’s comments, inserted at approval, are also visible on the Project Approval record. The Time Entry can now be approved from the ribbon by a Project Approver.As the entries have been approved, the field Approved by Manager has a value of Yes. Jane Doe’s comments, inserted at approval, are also visible on the Project Approval record. The Time Entry can now be approved from the ribbon by a Project Approver.

 

Rejecting Time Entries

 

rejecting-entries.pngThese entries will be rejected.These entries will be rejected.

rejected-entries-and-error-message.pngJane Doe has rejected these entries as the manager of John Doe. When attempting to approve the entry from the Project Approval record’s ribbon, an error is given as Approved by Manager has a value of No.Jane Doe has rejected these entries as the manager of John Doe. When attempting to approve the entry from the Project Approval record’s ribbon, an error is given as Approved by Manager has a value of No.

 

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

Comments

Great post, this looks really intresting. I would assume the same can be done for Expense Approvals?

Thanks for the feedback @SAG_Toma. Yep, can be done with expenses as well. The logic is the same.

Meet Our Blog Authors
  • Working daily with Microsoft Cloud to deliver the needs of my company, my customers and various Microsoft communities and forums. | Office 365 | Flow | PowerShell | PowerApps | SharePoint |
  • Co-founder of https://plumsail.com, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • Solution Architect with Slalom, and organizer of the Boston Office 365 User Group, and long term SharePoint/Office 365 veteren. Find more at http://www.davidlozzi.com. Follow @DavidLozzi
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Daniel is a Business Productivity Consultant & Microsoft Business Solutions MVP who is very enthusiastic about all things Office 365, Microsoft Flow, PowerApps, Azure & SharePoint (Online). Since the preview, Daniel has been working with Microsoft Flow and later on with Microsoft PowerApps. That led to him being awarded an MVP Award for Business Solutions. He loves to blog, present and evangelize about improving productivity in the modern workspace with these amazing tools!
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc ( https://triad.co.uk)