Pull catalog item variables into catalog task description

Dead Blade
Kilo Guru

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?

1 ACCEPTED SOLUTION

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.

View solution in original post

24 REPLIES 24

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.

That worked.... You ROCK!


Kunal Jha
Giga Expert

William,



What you intend is achievable.


But on catalog only client side code is done, still you can call server side code and make the description variable filled and finally in workflow you can populate the task description with description variable.



Instead of doing all that try a simpler way


In workflow populate task description will all the catalog Item variable you want.


task.description = current.variables.variable1+current.variables.variable2+ so on


Hi Kunal, I don't want to put that code in the workflow because we use the same workflow for most of our catalog items and different catalog items have different variables.   So if I define u_description in the Catalog item, then for the workflow I just use task.description = current.variables.u_description and it will work for all catalog items.  



Thank you for the suggestion, I had thought of that.


Sounds cool. Discussion always   target to right direction.