Example: Creating a custom metric to analyze the opportunity management process
This example shows how to create a custom metric to compute the opportunity amount in an opportunity management process.
Requirements
You must create a custom process that is named Opportunity Management Process with data that is mapped to the relevant column heading.
Overview
In IBM Process Mining, you can create custom metrics by using a JavaSript code to analyze the opportunity management process. In an opportunity management process, each case is an opportunity with a corresponding amount that is mapped as Opportunity_Amount
.
To compute and classify opportunities based on the values of Opportunity_Amount
, you must retrieve the Opportunity_Amount
of all the opportunity events by adding the code line in the Custom metric code field:
var amount = event.getDoubleCustomAttributeValue(‘Opportunity_Amount’);
After retrieving the event data, you classify the opportunity events per the conditions that you apply in the Custom metric code field.
In the custom metric code, you can apply the object methods, which are defined in the JavaScript Object methods for the case and event objects topic, on the case and event objects.
Procedure
To create the custom metric to classify the opportunity events based on the values of Opportunity_Amount
, do the following steps (see 'Video 1. Custom metrics for opportunity management process'):
-
In the Home > Recent projects > All projects > Assets > Projects.
-
In the Projects tab, select the Opportunity Management Process project from the Projects table.
-
In Opportunity Management Process, go to Manage > Custom Metric.
-
In the Custom Metric page, click Add new custom metric button to open the Create custom metric dialog.
-
In the Create custom metric dialog, do the following steps in the Details step:
-
Enter a name for the custom metric in the Name field.
-
Select String from the Data Type dropdown because the
result
must be a text string. -
Add description in the Description field if required.
-
Enter the following JavaScript code in the Custom metric code field.
var customMetric = { caseMetric: function(aCase) { var opportunity = ''; for(var k = 0 ; k < aCase.size(); k++) { var event = aCase.get(k); var amount = event.getDoubleCustomAttributeValue('Opportunity_Amount'); if (amount < 10000){ opportunity = '0-10k'; } else if(amount < 100000){ opportunity = '10k-100k'; } else if(amount < 500000){ opportunity = '100k-500k'; } else if(amount < 1000000){ opportunity = '500k-1M'; } else if(amount < 10000000){ opportunity = '1M-10M'; } else if(amount >= 10000000){ opportunity = '10M+'; } } return opportunity; } };
-
Click the Test Code button to validate the custom JavaScript code.
-
After the successful validation of the custom JavaScript code, click Next button to go to the Additional configuration step.
-
-
In the "Create custom metric" dialog, do the following in the Additional configuration step:
-
Enter the unit of the custom metric result in the Unit field.
-
In the Assign to categories section, you have two options namely, Select Existing category or Create New category.
-
To select an existing category, do the following:
-
Choose the Select Existing radio button in the Assign to categories section.
-
Choose a category by clicking on any related category tile. For example, select the Amount category.
-
Click the Create button to complete the creation of custom metric.
-
-
To create a new category to link the custom metric, do the following:
-
Choose the Create New radio button in the Assign to categories section.
-
Enter a name in the Name field.
-
Enter a description in the Description field.
-
Select an existing icon or add a new icon in the Icon field.
-
Click the Create button to complete the creation of custom metric.
-
Video 1. Custom metrics for opportunity management process
-
Result
After you complete the creation of the custom metric, you can see details of the created custom metric in the Custom metrics table in the Custom metrics page. The custom metric that you created to compute the
Opportunity_Amount
, assigns each class to an opportunity based on the opportunity amount of the last event in a case. Therefore, the custom metric considers only the last updated value of Opportunity_Amount
.