Business Problem: I want to know how long is spent in my business process by stage and by user how can I achieve this with no code?
The solution is actually quite simple if you are the latest release of Dynamics 365. The key to the solution is the fact that Dynamics now maintains the active stage and active start time for instance of a business process flow.
When you create a business process flow, a new entity is created to maintain the instances of the business process flow. So each time you start an opportunity, a business process record is created for the business process that is running that maintains the start time, active stage and status of that process. Thus when you switch process the previous process flow state is maintained.
So with this knowledge you now have a record that records the relationship to the business process and to the record it was initiated from.
Back to the problem. What I need is an entity to store the start and end time for each stage and a workflow that creates the record each time the stage changes. Simple as follows:
- Create a new entity, in my case I used an activity entity called Stage Duration. I used an activity entity, as it already has all of the fields that I need to record the stage duration i.e. Regarding, actual start, actual end, and subject. The one field that I did create is Stage duration, which is a decimal and is a calculated field. The calculation works out the difference between Actual End and Actual Start.
- Once I have published the entity I now need to create a workflow to fire each time the active stage changes for the business process that I want to monitor.
- Create a new process – workflow, select the newly created entity that corresponds to the business process that you want to monitor.
- Set the workflow to run on creation and when the active stage field changes.
- Now add action to create the stage duration activity, populate the subject with something like Stage: <<Active Stage>>, populate the actual start with the “Active Stage start time”, update the owner to the owner of the related record and set the regarding to the related record.
- Now add a wait step to wait until the active stage start time is not equal to the new activity creates actual start time.
- Then add the step to update the actual end time to that of the Active stage started on. (this is now the next stage started on time thus the end of the previous stage)
- That is it you now have a workflow that triggers at the start of the process and again each time the active stage is changed. That will record the start, end and duration of stage per process stage and user.
- Here is the workflow example below:
- Now each time I change the process a new activity is created as below:
- This allows me to create charts as follows, i.e. by stage average time, and by user by stage average time.
The possibilities are now endless to the types of things I can do i.e. alert if a stage has not changed after a given time period, alert if average time is over norm, create a nice dashboard to show exceptions or enable me to identify focus stages to work on.