Displaying catalog variables on catalog task created by run script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2015 08:15 AM
Hi, I have a requirement to create multple catalog task dimanically in workflow. I achived that by a run script using glide record. however Catalog variables are not showingup on the tasks created. Did any one try showing catalog variables on tasks created by a script.
16 REPLIES 16
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2018 05:56 AM
Less GlideRecord call of version above. Better or Same, not sure.
var scItemOptions = [];
var itemOptionNews = [];
var tsk = new GlideRecord('sc_task');
tsk.addQuery('request_item', current.sys_id);
tsk.query();
if (tsk.getRowCount() >= 1) {
var reqvar = new GlideRecord('sc_item_option_mtom');
reqvar.addQuery('request_item', current.sys_id);
reqvar.query();
while (reqvar.next()) {
scItemOptions.push(reqvar.sc_item_option.sys_id);
}
if (scItemOptions.length >= 1) {
var variablereference = new GlideRecord('sc_item_option');
variablereference.addQuery("sys_id", "IN", scItemOptions.join(","));
variablereference.query();
while (variablereference.next()) {
itemOptionNews.push(variablereference.item_option_new.sys_id);
}
if (itemOptionNews.length >= 1) {
for (var i = 0; i < itemOptionNews.length; i++) {
while (tsk.next()) {
var add_task_var = new GlideRecord('sc_item_variables_task');
add_task_var.task = tsk.sys_id;
add_task_var.variable = itemOptionNews[i];
add_task_var.insert();
}
tsk.restoreLocation(); // Reset Task Loop Location to 0
}
}
}
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2020 04:06 AM
Thanks stacey!! It worked for me