How to report on how many change requests have been changes its state from Work in Progress to Completed in a day?

Arpan6
Giga Guru

I have a requirement to report on when the state of a change request changes to get the count of records changed from 'new'   to 'work in progress' state or 'work in progress to completed' or 'completed to closed' etc. I have created a metric definition on 'change_request' table on the field 'state' with type 'field value duration' and reported on the 'Change Metric' database view. But I am only getting the count and time when it changes from a particular state (eg,   work in progress) but cannot determine the count that how many of them changes from 'work in progress to completed' or 'work in progress to cancelled'.

find_real_file.png

Here I am only getting the count that 33 change requests have change their state from 'Draft' state bu I want that out of that 33   how many change requests have changed their state from 'Draft' to 'Review'.

Does anyone have any idea how to do that?

1 ACCEPTED SOLUTION

Thanks Julian,



I have created a before   business rule on change_request table to capture it , and it works,


condition: current.state.changes()


(function executeRule(current, previous /*null when async*/) {



insertMetrics();



function insertMetrics() {


      var mi= new GlideRecord('metric_instance');


      //sys id of the metric definition


      var metricSysID = 'sys id of metric definition';


      mi.initialize();


      mi.definition = metricSysID;


      mi.start = previous.sys_updated_on;


      mi.end = gs.nowDateTime();


      mi.duration = gs.dateDiff(mi.start, mi.end);


      mi.id = current.sys_id;


      mi.value =     previous.state.getDisplayValue() + ' to ' + current.state.getDisplayValue();


      mi.calculation_complete = true;


      mi.insert();


}


})(current, previous);


View solution in original post

6 REPLIES 6

Julian Hoch
ServiceNow Employee
ServiceNow Employee

The metrics will not capture the start state, only the end state. With a scripted metric you can restrict it to only create entries if a certain starting state is matched, so for example if you want to know which ones go from WIP directly to closed complete. If you want to report on many different state sequences and especially if there might be intermediate states you don't care about, then it's getting tricky to report this with simple metrics.


Depending on your exact requirements, it might also be worth looking at Performance Analytics.


No, I want the start state and end state of a metric. i.e the previous state before the matrix was created or the next state the metric is changed to. As example, suppose the state of a change request has been changed from New to WIP , then I want to capture both the state New and WIP in a single metric , as it is required to show the change request has been changed directly from New to WIP, not intermediate states.


Julian Hoch
ServiceNow Employee
ServiceNow Employee

Well that's not possible with a single metrics definition as far as I know. You would have to set up multiple metrics to capture that.


Can you please guide me how to capture both the start state and end state using multiple metric definition?