Reporting - Updates

samdodd
Kilo Contributor

Hi All

I have a query as to whether a report can be run to show all userids that have updated a ticket and then filter out for specific users?

I can get the last updated but this isn't going to provide me what I need.

Any ideas would be much appreciated.

Sam

2 REPLIES 2

pravalika2
Kilo Expert

Hello Sam,



I suggest you to go through this link:               Metric


Here, in your requirement you might need to compare previous.sys_updated_by with current.sys_updated_by. So, you can create a metric to capture the updates and business rule to create metric instances whenever the sys_updated_by person changes.


Later you could create a report using table metric on which metric is written.


For more info from wiki:


Metric Definition Support - ServiceNow Wiki



Hope it helps you



Thanks & Regards,


Poojitha


pravalika2
Kilo Expert

Here is what I have tried:


I have created a metric named: 'Capture Updated by' for incident table


1.png


And a before business rule on incident table which creates metric instances in the above mentioned metric:


code:



function onBefore(current, previous) {


  if(current.sys_updated_by!=previous.sys_updated_by){


  insertMetrics();


  }


  function insertMetrics() {


  var mi= new GlideRecord('metric_instance'); //a new metric instance is created for the above metric definition


  var metricSysID = '8d19d81d0f0c6a0048430cbce1050ebc'; //sys_id of the metric 'Capture Updated By'


  mi.initialize();


  mi.definition = metricSysID;


  mi.field_value = previous.sys_updated_by;//field_value stores the previous value of updated by


  mi.start = previous.sys_updated_on;


  mi.end = gs.nowDateTime();


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


  mi.id = current.sys_id;


  mi.sys_updated_by = gs.getUser().name;//sys_updated_by stores the user name who has updated the incident ticket


  mi.calculation_complete = true;


  mi.insert();


  }


  gs.log('Metric trigger');


}



And here are the instances created:


2.png


You can create a report on incident metric like:


3.png



Thanks & Regards,


Poojitha