유용한 승인 할당 스크립트
유용한 승인 및 할당 스크립트의 검색 가능한 버전입니다.
탐색하기 쉬운 버전을 보려면 유용한 스크립트 포털을 방문하십시오 .
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
- 조건: current.assigned_to== '' && current.assignment_group != ''
- 시기: 이전, 삽입/업데이트
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();}범주 변경 시 담당 규칙 실행
유형: 클라이언트 스크립트.
테이블: 인시던트
// 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로 이동하여 UI 매크로를 클릭합니다.
- 기존 "approval_summarizer_sc_task"의 이름을 "approval_summarizer_sc_task_old"와 같은 이름으로 바꾸고 비활성화합니다.
- 같은 이름("approval_summarizer_sc_task")을 사용하여 새 항목을 만듭니다. 이름은 기본적으로 매크로가 수행하는 작업과 적용되는 내용을 알려야 합니다. 이 경우 기존 이름을 대체하므로 기존 이름을 다시 사용하기로 결정했습니다.
그런 다음 이 문서의 맨 아래에 있는 xml 스크립트를 새 UI 매크로의 xml 코드 창에 복사합니다. 이는 Service Catalog 실행 계획 내의 승인 작업을 사용하여 라인 항목 승인을 수행할 때 승인자에게 몇 가지 세부 정보를 제공하는 데 좋은 방법입니다.
다양한 방법
이전 방법
이는 이전 방법을 사용하는 승인 작업을 사용할 때 내 승인 에 표시되는 뷰입니다.
승인자에게 실제로 무엇을 승인하는지 알려주는 세부 정보는 많지 않습니다. 작업에 대한 짧은 설명은 볼 수 있지만 항목에 대한 정보는 많지 않습니다.
새로운 방법
OOB(바로 사용 가능) UI 매크로 대신 아래의 xml 스크립트를 사용하는 경우 표시되는 뷰입니다.
이 방법을 사용하면 요청 승인과 매우 유사한 상세 정보를 볼 수 있습니다. 주문한 항목에 대한 링크, 간단한 설명(항목에서 변수를 확장할 수 있는 기능 포함), 가격, 수량 및 총 가격이 있습니다. 이 방법은 더 자세한 정보를 표시한다는 점에서 승인자에게 도움이 됩니다. 이제 승인자는 실제로 승인하는 내용을 볼 수 있습니다.