Dynamics 365 Project Service Automation: Updating Invoice Line Details and Actuals with values from custom fields

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

On my previous post I wrote about using Flow to pass values from custom fields on Actuals throughout PSA’s end-to-end process. The Flows in my previous post used Time Entries as the source for a value for Case. This value was then carried throughout PSA’s end-to-end process from an Unbilled Sales Actual to a reversed Billed Sales Actual. In that scenario everything works just fine as long as the value for Case doesn’t need to change on an Invoice. If it does, there’s no way to change it as the Flows pull the value from a related Time Entry.

To change the value during the end-to-end process, we would have to follow PSA’s OOTB behavior of changing the desired values on an Invoice Line Detail. Example: A Time Entry is approved for 1 h. At Invoicing, we realize that 2 h should be billed. Quantity on the related Invoice Line Detail can be changed to 2 and when the Invoice is confirmed, a Billed Sales Actual is created with a Quantity of 2. The change to the Invoice Line Detail doesn’t trigger any immediate changes to its related Unbilled Sales Actual or any other record, until the Invoice is confirmed.

This makes the goal for this blog post pretty clear:

  • A Flow will update Invoice Line Details with Case from their related Unbilled Sales Actuals.
  • When an Invoice is confirmed, another Flow will update Billed Sales Actuals with Case from Invoice Line Details.
  • When an Invoice is corrected, the reversed Invoice Line Details will have the same value for Case as what is on the Billed Sales Actuals from the initial invoice confirmation.
  • When a corrected Invoice is confirmed, reversed Billed Sales Actuals and new positive Unbilled Sales Actuals will have the same value for Case as what is on the corrected Invoice’s Invoice Line Details.

Before we dive into the Flows, it’s kudos time to community super star MVP Jonas Rapp for helping me out with ODATA filter queries for both the previous post and this one. With a List records action it’s a good idea to keep the returned list short. Especially as the Flows on these two blog posts have several List records and Apply to each actions, the Flows take a while to execute.

Flows #1 and #2 were covered on the previous blog post. Flow #1 will update Cost and Unbilled Sales Actuals with Case from Time Entry and is thus a prerequisite to Flows #3 and #4 covered on this post. Flow #2 is “deprecated” and is replaced by Flows #3 and #4.

Flow #3 – Updating Invoice Line Details

This Flow updates Invoice Line Details with Case from Unbilled Sales Actuals when an Invoice is created. To access the correct Invoice Line Details, we must first list Transaction Connections related to the Unbilled Sales Actuals. We can then list all Invoice Line Details that are related to the Transaction Connections. The final action is to update the Invoice Line Details with Case from Actuals.

Invoice Line Details on a corrected Invoice need to be updated as well so that reversed Billed Sales Actuals will also have the correct value for Case. The actions on the “false” side of the Flow are the same as on the “true” side with one exception: The value for Case is pulled from Billed Sales Actuals, which are created when an Invoice is initially confirmed

Image 1: Flow #3.

Flow #4 – Updating Actuals

The previous Flow updated Invoice Line Details with Case from Actuals. Flow #4 will update Billed Sales Actuals, reversed Billed Sales Actuals and Unbilled Sales Actuals with Case from Invoice Line Details, when an Invoice is confirmed. The Flow works with both initial Invoice confirmations and when corrected Invoices are confirmed.

Transaction Connections are used to connect Actuals to Invoice Line Details. The actions in the Flow are similar on both the “true” and “false” sides of the Flow. The Filter Queries have some differences that can be seen in the images or by downloading the Flows.

Image 2: Flow #4.

This concludes my brief 2-part article series on passing values from custom fields on Actuals throughout PSA’s end-to-end process. I hope these Flows give you ideas on how to use data specific to your business in the entire end-to-end process. While Flow is a great tool for extending PSA, it’s important to remember that Flows are asynchronous. You will have to wait for Flow to update fields so running through the process fast will leave you with fields that have not been properly updated. Despite favoring a no-code approach, I would implement the functionality covered on these two blog posts with plug-ins, to see immediate results with fields updating.

As always, these Flows can be downloaded from the TDG Power Platform Bank here.

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