Metrics scripting

rezacol
Mega Expert

I want to capture the assignment group at the time of SLA breach on task table. So I am using the below code

if (current.active) {

      if (current.has_breached.getDisplayValue() == 'true') {

                createMetric();

      }

}

 

function createMetric() {

  var mi = new MetricInstance(definition, current);

  if (mi.metricExists())

      return;

 

  var gr = mi.getNewRecord();

  gr.field_value = current.task.assignment_group;

  gr.calculation_complete = true;

  gr.insert();

}

But this isn't capturing any records. Plese advice me where am i doing wrong   ?

1 ACCEPTED SOLUTION

Got the solution. I added metric event for task_sla table and now its working as per my requirement.


View solution in original post

12 REPLIES 12

pavan_poul
Kilo Expert

Hi Reza,



Could you please give clear idea why you are using Metric



If I am not wrong, you want to populate the group name when SLA breached.


It can be done with client script when SLA breached we can capture the current group of user and do the need full action by calling script include in client script like send notification.



Thanks,


Pavan


Hi Pavan



I need it for the reporting purpose. We need to create reports on a monthly basis for the tickets which has been breached(for all priorities) and which assignment group was in charge during the breach. Since I have seen scenarios where the assignment group changes after the ticket has been breached. So I want the correct assignment group who breached the ticket for business purpose.



Please help why my metric is not capturing any data.



Thanks,


Reza


Hi Reza,



Actually when your Metric runs that time which group is assigned will get that group only.


We dont have direct option to do this in service now to see the group which was there at the time of SLA breached.


For your requirement we can do like , will create one entry in one table at the time SLA breached, will use that table while creating report.



If you got an idea through this   please mark as answered one.



Thanks,


Pavan Poul


Thanks for the support but via metrics whenever the Has Breached value changes it will trigger the metrics instance to insert a record. So whenever any ticket breaches, that moment it will get the current assignment group and will create a new record in metric_instance table.



I am able to do other reporting stuffs through incident table via my custom metrics but using task_sla table it is somehow not triggering my metric.



Thanks,


Reza