cancel
Showing results for 
Search instead for 
Did you mean: 
anttipajunen

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.

 

Prevent entry approval before initial approval is processed.Prevent entry approval before initial approval is processed.Prevent entry approval before initial approval is processed.

Update Project Approval from Bookable Resource.Update 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

 

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

 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.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.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.

 The 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.The Flow has run successfully and the entries have been approved by the manager – Jane Doe.

 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.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.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

 

These entries will be rejected.These entries will be rejected.These entries will be rejected.

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.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.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.

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/