Skip to content

Commit a67cdb7

Browse files
authored
Merge branch 'ServiceNowDevProgram:main' into main
2 parents 94d4e3d + 7b51f11 commit a67cdb7

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use the script as Business Rule script on Catalog Task table which runs After Insert and will copy all MRVS values from RITM to Catalog Task for quick actions at the Catalog Task itself for reviewing and getting the work completed.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
3+
// Copies the values from a multi-row variable set into a variable so we can view the values on a catalog task.
4+
var variables = [];
5+
var catItem = current.request_item.cat_item.toString();
6+
var variableSets = [];
7+
var getVariableSets = new GlideRecord('io_set_item');
8+
getVariableSets.addQuery('sc_cat_item', catItem);
9+
getVariableSets.query();
10+
while (getVariableSets.next()) {
11+
variableSets.push(getVariableSets.getValue('variable_set'));
12+
}
13+
var getCatalogVariables = new GlideRecord('item_option_new');
14+
var qry = 'cat_item=' + catItem +
15+
'^active=true' +
16+
'^NQvariable_set.sys_idIN' + variableSets.toString() +
17+
'^active=true';
18+
getCatalogVariables.addQuery(qry);
19+
getCatalogVariables.query();
20+
while (getCatalogVariables.next()) {
21+
variables.push(getCatalogVariables.getValue('sys_id'));
22+
}
23+
var variablesCount = variables.length;
24+
var currentTaskID = current.sys_id.toString();
25+
for (var i = 0; i < variablesCount; i++) {
26+
var getTaskVars = new GlideRecord('sc_item_variables_task');
27+
getTaskVars.addQuery('task', currentTaskID);
28+
getTaskVars.addQuery('variable', variables[i]);
29+
getTaskVars.setLimit(1);
30+
getTaskVars.query();
31+
if (!getTaskVars.hasNext()) {
32+
getTaskVars.initialize();
33+
getTaskVars.setValue('task', currentTaskID);
34+
getTaskVars.setValue('variable', variables[i]);
35+
getTaskVars.insert();
36+
}
37+
}
38+
})(current, previous);

0 commit comments

Comments
 (0)