Dynamics 365 Project Service Automation: Custom Insight Cards in PSA with Flow

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

I recently replied to a question on the Dynamics Community forums about tracking end dates of Project Tasks and comparing them with related Milestones. The question was interesting because looping through all matching Project Tasks and Milestones due utcNow() is something that we need either code or Flow for. In addition, a follow up question to the original one could be “How can we visualize this information?”. Off the top of my head I can think of four ways: Send an email, visualize in Power BI, use a custom entity and OOTB charts and dashboards or use custom Insight Cards. For now, I’ll focus on the new, shiny and cool stuff: Custom Insight Cards.

What are these custom Insight Cards then? Docs.microsoft.com covers these well so hop over there for a second for some detailed info. In short: “The relationship assistant displays actionable insight cards (formerly called action cards) for users in Dynamics 365 for Sales. The relationship assistant is evolving and we’re introducing new preview capabilities such as customized insight cards to your team.” 

So why are these really cool? For starters, they are really simple to make: Flow and go! Insight Cards are also a really powerful way to gain insight into different important pieces of information, that require a user to take action. We can compose cards from data across different data sources, across entities in CDS and from different types of records filtered in various different ways.

For this blog post, the use case is as follows:
Display all Milestones that have Project Tasks associated to them with both Project Task End Date and Milestone Date being utcNow().

Reading the above, you probably realize there could be a time zone issue with what we’re trying to accomplish here. In PSA, date fields are Date Only, User Local. This means that you might have to play around with time zone conversions in your Flow to get everything working just the way you like. One option could be to change the behavior of the related fields in PSA but I’m personally not too thrilled about changing the behavior of OOTB date fields. In this example, my time zone in D365 CE is GMT +2 and the Flow is tailored to work specifically in this time zone with all date fields as they are OOTB.

Creating custom Insight Cards

After enabling the preview in your environment, it’s time to create an Insight Card. If you want your custom Insight Cards to be visible under the Manage insight cards tab on AI setup, the related Flow containing the action for the card must be created from AI setup. Flows created directly from flow.microsoft.com don’t show up under the Manage insight cards tab and then again Flows created from AI setup don’t appear under My Flows on flow.microsoft.com. It’s interesting to see what the experience for creating custom cards will be like when the feature is GA.

I encourage you to try creating custom cards in different ways. Keep in mind that it’s best practice to use solutions with Flows.

Image 1. Navigate to Sales Insights to access AI setup.
Image 2. Custom Insight Cards can be created from AI Setup.
Step 1

The Flow will be fired off based on values on a Recurrence trigger. The interval depends entirely on your business and needs. After the trigger, a Compose action has an expression that formats utcNow() so that its time component won’t cause issues later on in the Flow. The second action lists all Project Contract Line Milestones. We are interested in PCLMs that have a value in the Project Task field as this indicates that a PCLM and a Project Task are tied together. The Milestone Date should match the output of the Compose action. This way we will get PCLMs due today / due utcNow().

Image 3. Trigger and first two actions.
Image 4. Project Contract Line Milestone with Project Task and Milestone Date.
Step 2

In the second step, a Get Records action is used for PCLMs and Project Tasks. The actions are run inside an Apply to each loop. A condition checks that a Milestone Date equals a Project Task’s End Date. Depending on the time zone and the behavior of date fields, expressions may be needed to get the dates on the fields to work just right. In my case I have to add a day to Milestone Date (time zone was EEST and field behavior the OOTB User Local). The expression for this is:
addDays(body(‘Get_PCLM’)?[‘msdyn_invoicedate’],1,’yyyy-MM-dd’)

Image 5. Apply to each in Flow.
Step 3

The 3rd and last step is to use the Get Record action for Projects and Users. This way we can create a custom card that can be displayed to a Project’s owner on the Project record. Instead of Owner, Project Manager could be used as well. What is used on Display to really depends on your use case.

The Action on the insight card action is set to Open Entity. As Action Input and Set Regarding are populated with a dynamic value for a Project, clicking on the header of an insight card will open the related Project record. This makes navigating to records a lot easier.

Image 6. Creating a custom Insight Card.

The results

When the Flow is successfully run, a new custom Insight Card is created. For this example, I’m displaying the cards on a custom tab on the Project record as well as on a dashboard. One thing worth mentioning is that the description area of an insight card only holds approximately 3 lines of text. I have created an idea on experience.dynamics.com to increase the current limit. The idea can be voted up here.

Image 7. Insight card on dashboard.
Image 8. Insight card on Project.

As always, this Flow can be downloaded from the TDG Power Platform Bank here. Custom Insight Cards are a great way to delivered tailored content to users in D365 CE. I highly encourage you to try them out!

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