BPF Automation Scenario – Preserving History of Stage Duration

If you have used BPF, you would know that the BPF control on the form shows the time spent on the current stage, however, as soon as you transition forward or backward to a different stage, that duration is lost and a new duration starts showing in the newly transitioned Stage. What if you wanted to keep track of the history of all the time spent on each stage?

In this post, I will be showing you an application of the BPF automation concepts by preserving the history of the duration spent in the BPF Stages. In case you did not check out my previous post, you can check it out here.

Concept

We know that the BPF entity (which corresponds to your Business Process Flow) has a number of fields that hold valuable information. From those fields, a few that will help us preserve the history of duration spent on each stage are as follows:

  • Active Stage
  • Active Stage Started On

Whenever the BPF is activated i.e. the first stage is set as the current stage or when the stage is transitioned to a new stage which happens when you click the Next or Back button on the BPF control, the values of Active Stage and Active Stage Started On are updated. In order to preserve the history of the time spent on each stage, we will have to preserve these two fields before they get overwritten.

Solution

In order to preserve the history, I will need an entity which will save the record for each stage including the Active Stage Started On (datetime) before the BPF entity overwrites that information. Below is the structure of this custom entity called “Stage Duration History”. Additionally, depending on the specific BPF, you may wish to keep track of the related entities that correspond to each of the BPF Stage. In my example, I am going to keep track of stage duration history for the OOB “Opportunity Sales Process”.

Custom Entity

Field NameType
Process Instance Lookup (Opportunity Sales Process)
OpportunityLookup (Opportunity)
StageLookup (Process Stage)
Started OnDate and Time
Ended OnDate and Time
DurationWhole Number (Calculated)

The Duration Field is a calculated field and it calculates the duration in minutes as follows:

DIFFINMINUTES(<started on>, <ended on>)

Workflow

We know from BPF Automation Concepts that we can create a workflow on the BPF entity. In this scenario, I am going to define a Real Time workflow on the “Opportunity Sales Process” entity and the trigger conditions will be:

  • On Change of Active Stage
    This will ensure that any time the stage changes, the duration of the previous stage is saved in the custom entity.
  • On Status Change of the BPF entity
    This will ensure that if the process becomes inactive i.e. it either gets finished successfully or is abandoned, the timer stops and the duration of that particular stage is saved as history.Remember, when this BPF reactivates again (when the user reactivates the process), the Active Stage Started On is reset and therefore we do not want to lose this information that can be used to preserve the duration before it got deactivated.

If you are wondering why I have used a real time workflow, the answer is simple. I want to perform this operation prior to the actual update operation to the BPF entity and therefore I have to get the history record generated in the actual transaction before the system performs the core operation. Here is how the workflow definition looks like.

Note: Make sure you add ‘Create’ privilege to any security roles that will be applied to users working on this process since the workflow is being triggered as the User and not the Owner of the process. Running it as the user will also allow you to see who did the stage transition if multiple users are working on the same process.

Result

Here is how it works once implemented.

Once you start capturing the history of stage duration, you can use this information to gain insights into how well your processes are working from operational standpoint and if there are any bottlenecks that need to be removed.

3 thoughts on “BPF Automation Scenario – Preserving History of Stage Duration

  1. Hi there, great post. For the custom entity that use to preserve the history (i.e. Stage Duration History) how do you setup the relationship of this custom entity with the record it is related to?

    1. Hi,
      As you can notice, one of the fields in the custom entity (Stage Duration History) is a lookup to Opportunity. That is how this custom entity has a Many to One relationship with the entity it is related to. When a new stage history record is created, this lookup is populated as part of the workflow.

Comments are closed.