Thank you for your feedback.
Form temporarily unavailable. Please try again or contact to submit your comments.
  • London
  • Kingston
  • Jakarta
  • Istanbul
  • Helsinki
  • Geneva
  • Store

Sample field value duration script

Sample field value duration script

Review the existing Incident Open metric definition to see how you can create your own custom metric.

This script either provides a duration value or stops processing durations (sets the answer variable to false) when an incident is closed.

    // script can set answer to false to terminate processing of the metric
    // mi - MetricInstance
    // answer
    if (! {
    answer = false;
    gs.log("Closing field durations");
    function closeDurations(current) {
    var gr = new GlideRecord('metric_instance');
    gr.addQuery('id', current.sys_id);
    gr.addQuery('calculation_complete', false);
    gr.addQuery('definition.type', 'field_value_duration');
    while ( {
    gs.log("closing: " + + " for: " + current.number);
    var definition = new GlideRecord('metric_definition');
    var mi = new MetricInstance(definition, current);

Changes to site functionality will be made starting around 6am on January 21st (Pacific Time) and lasting approximately 6 hours.  The site may be intermittently unavailable.