---
sourceDocument: 호주 API 참조
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/api-reference

 Release :

    - australia

ft:locale :

    - ko-KR

ft:publication_title :

    - 호주 API 참조

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# 승인 할당 스크립트

# 승인 할당 스크립트 {#ariaid-title1}

* 릴리스 버전: Australia
* 
* 업데이트 날짜 2026년 03월 12일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 8분

유용한 승인 및 할당 스크립트의 검색 가능한 버전입니다.
경고:  
여기에 설명된 커스터마이제이션은 특정 인스턴스에서 사용하기 위해 개발되었으며 에서 지원되지 Now Support않습니다. 이 메서드는 있는 그대로 제공되며 구현하기 전에 철저하게 테스트해야 합니다. 이 커스터마이제이션에 대한 모든 질문과 의견을 커뮤니티 [포럼](http://community.service-now.com/)에 게시하십시오.

참조.[Viewing my approvals](https://www.servicenow.com/docs/access?context=viewing-my-approvals&version=australia&pubname=australia-security-management&ft:locale=en-US)

ESS 요청에 대한 그룹 할당
:
    다음 할당 규칙 스크립트는 모든 ESS 요청에 대한 그룹을 자동으로 할당합니다.

        if(current.opened_by.roles==""){
            current.assignment_group.setDisplayValue('Network');
            current.update();}


제공 계획 작업에 따라 그룹에 카탈로그 항목 할당
:
    이 할당 규칙은 데스크톱 그룹에 할당된 카탈로그 작업이 있는 제공 계획을 사용하는 경우 데이터베이스 그룹에 서비스 카탈로그 항목을 할당합니다.

        //Return catalog items that have no group but do have a delivery plan assigned
        var ri =new GlideRecord("sc_cat_item");
        ri.addQuery("group","=",null);
        ri.addQuery("delivery_plan","!=",null);
        ri.query();
        while(ri.next()){
            gs.log("Found an item");
            //Return tasks that point to the same delivery plan as the above item
            var dptask =new GlideRecord("sc_cat_item_delivery_task");
            dptask.addQuery("delivery_plan","=",ri.delivery_plan);
            dptask.query();while(dptask.next()){
                gs.log("Found a task");var gp = dptask.group.getDisplayValue();
                gs.log(gp);//If the task is assigned to desktop, assign the item's group to desktop
                if(dptask.group.getDisplayValue()=="Desktop"){
                    ri.group.setDisplayValue("Desktop");
                    gs.log("updating "+ ri.getDisplayValue());
                    ri.update();break;}}}


하나의 작업으로 항목 할당
:
    이 할당 규칙은 특정 그룹과 연결된 작업이 하나뿐인 모든 카탈로그 항목을 자동으로 할당합니다.

        //Get the catalog item for the current requested item
        var scCatItem =new GlideRecord("sc_cat_item");
        if(scCatItem.get('sys_id', current.cat_item)){
        // If the catalog item already has an assignment group or if using workflow we don't need to make an assignment
          if(!scCatItem.delivery_plan.nil()&& scCatItem.group.nil()){
                var dpTask =new GlideRecord("sc_cat_item_delivery_task");
                dpTask.addQuery("delivery_plan","=",scCatItem.delivery_plan);
                dpTask.query();
                if(dpTask.getRowCount()==1&& dpTask.next()){
                // Check that there is only 1 record in the GlideRecord
                    dpTask.group;}}}


작업 부하에 따른 할당

:   유형: 비즈니스 규칙

    설명: 활성 인시던트가 가장 적은 할당 그룹 구성원을 기준으로 할당 대상을 채웁니다.  
    매개변수:

    * 순서: \>1000 할당 규칙 이후에 실행하려는 경우
    * condition: current.assigned_to == '' \&; \& current.assignment_group != ''
    * 시기: 이전, 삽입/업데이트
    {#r_UsefulApprovalAssignmentScripts__ul_abh_ksv_qx}  

        var assignTo = getLowestUser();
        gs.addInfoMessage("assigning to is "+ assignTo);
        current.assigned_to= assignTo;
         
        function getLowestUser(){
          var userList =new Array();
          var cg =new GlideRecord('sys_user_grmember');
          cg.addQuery('group', current.assignment_group);
          cg.query();
          while(cg.next()){
            var tech = cg.user.toString();
            var cnt = countTickets(tech);
            gs.addInfoMessage("Tech counts "+ cg.user.name+' '+ cnt +" "+ tech);
            userList.push({ sys_id: tech,name: cg.user.name, count: cnt });}

          for(var i=0; i < userList.length; i++){
            gs.addInfoMessage(userList[i].sys_id+" "+ userList[i].name+" "+ userList[i].count);}
          userList.sort(function(a, b){
            gs.addInfoMessage("Sorting: "+ a.sys_id+"("+ a.count+");
            "+ b.sys_id+"("+ b.count+")");
            return a.count- b.count;});

          if(userList.length<=0)return"";
          return userList[0].sys_id;}
         
        function countTickets(tech){
          var ct =new GlideRecord('incident');
          ct.addQuery('assigned_to',tech);
          ct.addQuery('active',true);
          ct.query();
          return ct.getRowCount();}

범주가 변경되면 담당 규칙 실행

:   유형: 클라이언트 스크립트.

    테이블: 인시던트  
    설명: 이 예는 인시던트 내 범주 필드의 onChange 클라이언트 스크립트입니다. 참고: 이 스크립트는 동기 AJAX를 사용하는 데 사용됩니다(비동기 동작은 ajaxRequest 호출의 세 번째 매개변수에 의해 지정됨). 아래 구현은 비동기 AJAX를 사용합니다. 동기 버전 사용의 단점은 네트워크 응답 문제로 인해 브라우저가 중단될 수 있다는 것입니다.

        // Make an AJAX request to the server to get who this incident would be
        // assigned to given the current values in the record. This runs the assignment 
        // rules thathave been defined in System Policy and returns the assigned_to and 
        // the assignment_group
         
        function onChange(control, oldValue, newValue, isLoading){
          if(isLoading){return;
          // No change, do not do anything
          }

           // Construct the URL to ask the server for the assignment
          var url ="xmlhttp.do?sysparm_processor=AJAXAssignment&sys_target=incident";
          var uv = gel('sys_uniqueValue');
          if(uv){
                url +="&sys_uniqueValue="+ uv.value;}
          // Make the AJAX request to the server and get the response
          var serial = g_form.serialize();
          // get all values currently assigned to the incident
          var response = ajaxRequest(url, serial,true, responseFunc);}
         
        // This callback function handles the AJAX response.
        function responseFunc(response){
          varitem= response.responseXML.getElementsByTagName("item")[0];
          // Process the item returned by the server
          if(item){
          // Get the assigned_to ID and its display value and put them on the form
            varname=item.getAttribute("name");
            var name_label =item.getAttribute("name_label");
            if(name_label &&name){
              g_form.setValue('assigned_to',name, name_label);}
            else{
              g_form.setValue('assigned_to','','');}
            // Get the assignment_group ID and its display value and put then on the form
            var group =item.getAttribute("group");
            var group_label =item.getAttribute("group_label");
            if(group_label && group){
              g_form.setValue('assignment_group', group, group_label);}
            else{
              g_form.setValue('assignment_group','','');}}}

사용자 지정 승인 UI 매크로
:   사용자 지정 승인 UI 매크로 만들기에 대한 자세한 내용은 다음 문서를 참조하십시오 [UI 매크로](https://servicenow-prod.fluidtopics.net/~i5pOxozTXC72g_L_SQMxw#c_UIMacros "UI 매크로는 관리자가 사용자 인터페이스에 추가할 수 있는 개별 스크립트 구성요소입니다.").

