- 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 01:16 PM
I always thought you were trying to implement this code on the workflow of the service catalog. Any reasons for avoiding workflow? You might be spared of creating an extra script else.
Oh btw current methods doesn't works in client script. I even saw you using on submit client script,again any particular reason? Using on submit, you don't even have the control over the new record that is being created.
Use onload.
Use var str= g_form.getValue('variables.variable1');
var str2="\nNew line"+g_form.getValue('variables.variable2');//etc
var str_m=str+str1+;
g_form.setValue('description',str_m);
Great!
But I would still prefer using run script.
Oh yes ,in task.description = current.variables.u_description +"\n1"current.variables.u_cube_office + "\n2" + current.variables.u_startdate; you were missing a + between "\n1"+current. LoL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2017 09:49 AM
Just wondering, if you had tried my suggestion?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2017 01:33 PM
I have not, because there are many Catalog Items and this would not work across different items in one workflow. As I understand the script.
I did try the Catalog Item Client Script and it did not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2017 01:59 AM
William,
Please let me understand what are you trying to do?
So you are trying to populate all the description field (task table) for all the catalog item that creates the task records?
May i please know the reasons why are you trying to do such?
Technically , you can , but question is if you should.
Ill assume you have atleast 5+ catalog items (for serving various purpose) that may create tasks,and in those there could be several variables. Now,why would you let the functioning of all the catalog item look alike?
Plus, with so many catalog items ,name of the variables must have been different(advisable),even if not ,full chances you might miss variable's name at certain point of your work. And chances even are you may create new catalog items further, and then again you would need to make variables identical.
Chances even are, you may fail to diagnose an error at later stage of the instance.
As a better solution, i would tend to chose the tedious path i.e to set description per catalog item ,rather than setting up a global rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2017 11:45 AM
Hi Sharique, yes I understand the question, should we? Currently our Request only produce one task, so in that sense yes we would like to populate the Task Description with all the variables from the Catalog item that is true.
Thinking ahead, when we start having requests that create multiple items/tasks I would assume that we will use a different workflow.
I have looked into using business rules as well, but unable to populate the task description from catalog item variables.