- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017 08:58 AM
I have been looking at all the different post about pulling catalog item variable into the catalog task. Most of the post have been about pulling variables into the short.description. I would like to pull selected variable into the DESCRIPTION of the task.
My thoughts are to have a script within the Catalog item add all the variables that I wish to apply to the DESCRIPTION into one variable. Example var u_description = Var1 + Var2 + Var3 + ext.
Then in the Workflow apply task.description = current.variables.u_description.
With this ideology I can use one workflow, but in each catalog item I can define the variables I wish to apply to the task DESCRIPTION by adding them to u_description within the Cat Item.
Your thoughts please? And how do I apply this script to the Catalog Item?
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2017 12:59 PM
Can you try the below script. It is a onBefore Insert/Update business rule on Catalog task table
var keys = new Array();
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.request_item);
set.load();
var vs = set.getFlatQuestions();
var description =''
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '' && vs.get(i).getDisplayValue() != '' && vs.get(i).getDisplayValue() != 'false') {
description = description +vs.get(i).getLabel() + " : " + vs.get(i).getDisplayValue() + "\n";
}
}
current.description = description;
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017 10:12 AM
Hi William,
Add the below script in the catalog task advanced script section and it will set the description by concatenating all the values.
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.request.sys_id);
gr.query();
while(gr.next()) {
// Get Owned Variables for Requested Item and sort by Order
var ownvar = new GlideRecord('sc_item_option_mtom');
ownvar.addQuery('request_item.number', gr.number);
ownvar.addQuery('sc_item_option.value','!=','');
ownvar.orderBy('sc_item_option.order');
ownvar.query();
var items = "Description " + "\n";
while(ownvar.next()) {
var field = ownvar.sc_item_option.item_option_new;
var fieldValue = ownvar.sc_item_option.item_option_new.name;
// Print variable name
items += field.getDisplayValue() + ": " + gr.variables[fieldValue].getDisplayValue() + "\n";
}
task.description = items;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017 11:45 AM
Hi Vinoth, where is the Advanced Script section of the Catalog Item, I do not see that option. I have either UI Policy or Client scripts.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2017 06:36 AM
HI William,
I am also referring to put it in the workflow of catalog task activity. If you want to execute this activity for only some catalog item and this workflow is shared for multiple catalog item, you can also have a check in the workflow to check only if the requested item catalog item is so and so..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2017 09:42 AM
Hi Vinoth, my team and I are testing this in the workflow. So far it is not working. We are diagnosing the gs.logs.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2017 01:46 PM
You need a onBefore update/insert business rule on catalog task table with below script
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.request_item);
gr.query();
while(gr.next()) {
// Get Owned Variables for Requested Item and sort by Order
var ownvar = new GlideRecord('sc_item_option_mtom');
ownvar.addQuery('request_item.number', gr.number);
ownvar.addQuery('sc_item_option.value','!=','');
ownvar.orderBy('sc_item_option.order');
ownvar.query();
var items = "Description " + "\n";
while(ownvar.next()) {
var field = ownvar.sc_item_option.item_option_new;
var fieldValue = ownvar.sc_item_option.item_option_new.name;
// Print variable name
items += field.getDisplayValue() + ": " + gr.variables[fieldValue].getDisplayValue() + "\n";
}
current.description = items;
}
Please mark this response as correct or helpful if it assisted you with your question.