Dynamics 365 Project Service Automation: Using Flow to create a Project with tasks based on Project Contract Line Details

Tested on:
Dynamics 365 CE version 9.1, PSA solution version 3.6, Unified Interface

By default, Project Contract Line Details (later referred to as PCLDs) can be created by importing Project Task and Expense Estimate details from a Project. This is a fast way of creating a frame for an Order and Order Line. Data for PCLDs doesn’t have to be typed in again manually, if a Project with tasks has been created. The same exact logic works for Quotes as well.

Import from Project Estimation creates Project Contract Line Details based on a Project’s tasks and Expense Estimates.

While the approach of Project to Order or Project to Quote is certainly helpful in situations where an organization has a project’s structure all set up, the approach doesn’t work when an organization wants to create a Project based on an Order or a Quote. One of the most frequent requests I hear is to be able to create a Project with tasks based on Quote Line Details or PCLDs. I’ve heard many customers comment that the logic of Project to Order or Project to Quote is reversed – information is moving in the wrong direction.

Naturally this challenge can be overcome with a plug-in, but there’s also a way we can pull this off with Flow. The challenge with Flow is that if a Project has already been created from PCLDs, an error message on the UI can’t be shown. A push notification could work but personally I’m not a fan of the idea of producing those on mobile. They should be visible on the UI.

I naturally refused to accept that I can’t get a notification on the UI when a Flow updates a field in D365 CE so I asked around a bit. Who do I turn to with D365 CE Flow questions? MVPs Elaiza Benitez or Jerry Weinstock. This time it was Elaiza, and she immediately remembered that there is a community tool by Bruce Sithole that creates notifications on the UI. This tool is called 365 Notify and it can be downloaded from AppSource. Huge kudos to Bruce for creating this tool!

Setting up 365 Notify

Before we can build the Flow that creates a Project and tasks, 365 Notify needs to be installed and set up. The instructions for doing all that are very good and easy to follow, so instead of rewriting them on this post, I’ll only point out two details that I had to do to get notifications on my UI working:

  1. A value on a custom field is what fires off a real-time 365 Notify workflow to produce notifications on the UI (in my case Chrome). A value on this field is changed with the Flow that is covered later on this post. I’ve created the field under an Admin tab on the Order Line entity’s main form.
  2. When setting up the 365 Notify workflow, a Recipient record URL is needed so that notifications are displayed. The Dynamic Values I used are Modified by (User), Record URL (Dynamic).
Custom field on Order Line entity’s form.
365 Notify workflow’s Custom Step Input Properties.
Dynamic Values for Recipient record URL.

The Flow that creates a Project with tasks from Project Contract Line Details

The goal is to create an on-demand Flow that creates a Project with Project Tasks from PCLDs. If a Project is already associated to an Order Line, a notification created by 365 Notify will be shown on the UI. As Flow is asynchronous, we have to accept the fact that it might take 5-10 seconds for the notification to appear on the UI (in this example Chrome).

The Flow that we’re building is pretty simple. If a there is no Project associated to the Order Line from which the Flow is being fired off of, a new Project is created. Project Tasks are created based on the PCLDs on the Order Line. In other words the PCLDs become the Project Tasks. It’s important to remember that there are PCLDs of Cost and Project Contract. We’re interested in the sales side of things so the List PCLDs related to Order action must have a Filter Query that has a filter of msdyn_transactiontypecode eq 192350004. Otherwise there will be duplicate Project Tasks for the Project.

The WBS ID of a Project Task has to be unique and the easiest way to create unique WBS IDs is to increment a variable. The IDs start from 1 and end with whatever the number of the last task is. When the Project and its tasks have been created, the new Project is associated to the Order Line.

If a Project is already associated to an Order Line, we want to display a notification for the user about this. This is where 365 Notify comes in. The Flow updates the value on the custom field that was created earlier. When the value on the field changes, the real-time workflow for 365 Notify fires off and displays a notification on the UI. The Flow is then terminated as cancelled.

Notification by 365 Notify when a Project already exists.
Project Contract Line Details to Project and Project Tasks.

This blog post shows how we can accomplish a pretty frequent PSA requirement of creating a Project with tasks based on Project Contract Line Details. As always, this Flow can be downloaded from the TDG Power Platform Bank here.

Disclaimer:
All my blog posts reflect my personal opinions and findings unless otherwise stated.

Leave a Reply

Your email address will not be published. Required fields are marked *