Want to create a MTTR Response incident report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 04:26 AM
I Want to create a MTTR Response incident report from 'Created to Assigned to'. Need to calculate time duration from Incident created to gets assigned to someone.
This is Metric Definition for 'Create to Resolve Duration'
Code -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 07:18 PM
Sorry my friend, I am not a developer so scripting is not my area.
@Sandeep Rajput @Community Alums @Mark Manders can you help here.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 11:02 PM
Just don't. Use the SLA's for this. They want to report on this, so create a report on the task_sla table. You are there to provide them with the best possible solution. Metrics can have huge performance implications.
You need to provide your clients with this information, because 'this is what we already have/did' does not make it the best solution. Please let the SLA engine take care of this requirement.
Your metric script would look like this, but just don't use it.
var previousAssignedTo = current.getPreviousValue('assigned_to'); // Get the previous value of assigned_to
var currentAssignedTo = current.getValue('assigned_to');
if (!previousAssignedTo && currentAssignedTo) {
createMetric();
}
function createMetric() {
var metricInstance = new MetricInstance(definition, current);
if (metricInstance.metricExists())
return;
var newRecord = metricInstance.getNewRecord();
newRecord.setValue('start', current.getValue('sys_created_on'));
newRecord.setValue('end', current.getValue('sys_updated_on'));
newRecord.setValue('duration', gs.dateDiff(newRecord.getDisplayValue('start'), newRecord.getDisplayValue('end')));
newRecord.setValue('calculation_complete', true);
newRecord.insert();
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark