Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

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


Thanks for sharing!


Hi Poul, I am very new   to scripting. I understand completely what you are doing , would you possibly have an example of the script you used to accomplish this ?



Thanks


rezacol
Mega Expert

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


charlsouma
Kilo Explorer

Hi Reza,



I am new to ServiceNow. In our previous service management system we could identify the team where the SLA breached, but it isn't possible in Service Now OOB, however I believe metrics are the answer for this. I also need to report on SLA breaches monthly per team as part of the monthly SIP process.



I do not know enough about metrics to apply it to my problem. Could you explain what you changed so that it worked or possibly post a screeshot of your metric definiton.



thank you


Charl