CatalogItemVariableSet - 범위 지정됨
CatalogItemVariableSet API는 스크립트를 사용하여 서비스 카탈로그 항목 변수 세트를 만들고 수정할 수 있는 메서드를 제공합니다.
이 API는 sn_sc 네임스페이스에서 실행됩니다.
CatalogItemVariableSet - 작성(부울 standardUpdate)
정의된 카탈로그 항목 변수 세트를 삽입합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 표준 업데이트 | 부울 | 엔진과 워크플로우의 실행을 활성화할지 여부를 나타내는 플래그입니다. 유효한 값은 다음과 같습니다.
|
| 유형 | 설명 |
|---|---|
| 문자열 | 삽입된 변수 기록의 Sys_id입니다. |
// Given an existing catalog item
var catItemSysId = "e0d08b13c3330100c8b837659bba8fb4";
addVariableSets(catItemSysId);
function addVariableSets(catItemSysId) {
// List of all variable sets to attach
var myVarSets = [];
// Create variable set
var myVarSetAttrs = {"name": "Requester details", "order": "100"};
var myVarSet = new sn_sc.CatalogItemVariableSet();
myVarSet.setAttributes(myVarSetAttrs);
var myVarSetId = myVarSet.create(true);
myVarSets.push(myVarSetId);
}
카탈로그 항목변수 세트 - deleteRecord(부울 standardUpdate)
변수 세트를 삭제합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 표준 업데이트 | 부울 | 엔진과 워크플로우의 실행을 활성화할지 여부를 나타내는 플래그입니다. 유효한 값은 다음과 같습니다.
|
| 유형 | 설명 |
|---|---|
| void |
이 예제에서는 내 변수 세트를 사용하는 모든 카탈로그 항목에서 내 변수 세트를 제거한 다음 내 변수 세트를 삭제합니다.
// Get the sys_id of the variable set you want to delete
var vSet = new GlideRecord('item_option_new_set');
vSet.addEncodedQuery('title=My Variable Set'); // find My Variable Set
vSet.query();
if (vSet.next()) {
// first remove the variable set from all catalog items
var catItemVset = new GlideRecord('io_set_item'); // M2M table linking variable set and catalog item
catItemVset.addQuery('variable_set', vSet.getUniqueValue); // find all catalog items using My Variable Set
catItemVset.query();
while (catItemVset.next()) {
var vsetM2M = new sn_sc.CatalogItemVariableSetM2M(catItemVset.getUniqueValue()); // io_set_item M2M record sys_id
vsetM2M.deleteRecord(true); // delete M2M record
}
// then delete the variable set record
var varset = new sn_sc.CatalogItemVariableSet(vSet.getUniqueValue());
varset.deleteRecord(true);
}
CatalogItemVariableSet - 읽기(객체 열, 부울 standardUpdate)
카탈로그 항목 변수 세트 속성 값의 매핑을 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 열 | 객체 | 값을 지정할 열 집합을 지정합니다. |
| 표준 업데이트 | 부울 | 엔진과 워크플로우의 실행을 활성화할지 여부를 나타내는 플래그입니다. 유효한 값은 다음과 같습니다.
|
| 유형 | 설명 |
|---|---|
| 객체 | 열 이름을 값에 매핑하는 개체입니다. |
CatalogItemVariableSet - setAttributes(객체 속성)
변수 세트의 속성을 설정합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 속성 | 객체 | 열 이름을 값에 매핑하는 개체입니다. |
| 유형 | 설명 |
|---|---|
| void |
이 예시에서는 변수 세트를 만든 다음 새 세트에 변수를 추가합니다.
createVariableSet('My Variable Set', 'This is my test variable set', '100', 'one_to_one');
function createVariableSet(name, description, order, type) {
var myVarSet = new sn_sc.CatalogItemVariableSet();
// fields used in object are from table item_option_new_set
var myVarSetAttrs = {
"name": name,
"description": description,
"order": order,
"type": type
};
myVarSet.setAttributes(myVarSetAttrs);
var myVarSetId = myVarSet.create(true); // returns the sys_id of the created variable set
gs.info('Variable set created in table item_option_new_set with sys_id ' + myVarSetId);
// add a variable to the newly created variable set
var myVar = new sn_sc.CatalogItemVariable();
var myVarAttrs = {
"type": "6", // type 6 is single line text
"variable_set": myVarSetId.toString(),
"question_text": "Example question",
"name": "example_question",
"order": 200
};
myVar.setAttributes(myVarAttrs);
myVar.create(true);
}
출력:
Variable set created in table item_option_new_set with sys_id e21df65a1bff7c10593876a61a4bcbc4
CatalogItemVariableSet - update(객체 columnValues, 부울 standardUpdate)
변수 세트를 업데이트합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| columnValues | 객체 | 열 이름을 값에 매핑하는 개체입니다. |
| 표준 업데이트 | 부울 | 엔진과 워크플로우의 실행을 활성화할지 여부를 나타내는 플래그입니다. 유효한 값은 다음과 같습니다.
|
| 유형 | 설명 |
|---|---|
| void |
이 예에서는 표준 직원 질문 변수 세트에 대한 설명과 순서를 업데이트합니다.
// Get the sys_id of the variable set you want to update
var vSet = new GlideRecord('item_option_new_set');
vSet.addEncodedQuery('title=Standard Employee Questions'); // find the Standard Employee Questions variable set
vSet.query();
if (vSet.next()) {
var varset = new sn_sc.CatalogItemVariableSet(vSet.getUniqueValue());
var attr = {
'description': 'This should be used for all end user requests such as phones, tablets, etc. \n My description line',
'order': '500'
};
varset.update(attr, true);
}