---
sourceDocument: 요코하마 ServiceNow AI 플랫폼 관리
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/yokohama/platform-administration

 Release :

    - yokohama

ft:locale :

    - ko-KR

ft:publication_title :

    - 요코하마 ServiceNow AI 플랫폼 관리

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# 샘플 필드 값 기간 스크립트

# 샘플 필드 값 기간 스크립트 {#ariaid-title1}

* 릴리스 버전: Yokohama
* 
* 업데이트 날짜 2025년 01월 30일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 1분

기존 인시던트 열기 메트릭 정의를 검토하여 사용자 지정 메트릭을 생성하는 방법을 확인합니다.

이 스크립트는 인시던트가 종결되면 지속 시간 값을 제공하거나 지속 시간 처리를 중지합니다(응답 변수를 false로 설정).  

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


