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

Sharique Azim
Mega Sage

Hi,


I think there is a basic confusion here,


by current.variables.u_description, we mean the variable on the catalog item . But by var variables= etc.. we mean to declare a   variable within the script and has nothing to do with the catalog item variables.



Am i missing anything here, then please let me know?


Currently, I can define a variable as u_description in the catalog item and in the workflow I can define "task.description = current.variables.u_description" to populate u_description to the TASK Description created by the Catalog Item (RITM).     What I would like to do is within the catalog item assign many variable to the variable u_description.   Example var1 and va2, etc... so var u_description = var1 and var2, etc... so that in the workflow script "task.description = current.variables.u_description" will put the u_description that contains all the variables selected in the TASK Description.   Example:



TASK DESCRIPTION:    


User Name


Laptop #


Software Requested:   Adobe, Camtasia


Location:   North America


Etc...



Am I making sense?


Okk,   i think you want to populate the values of different variables of the catalog item into the description field of catalog task form?



Yes, you can!



try using the script:


task.description = current.variables.u_description +"\nUser Name"+current.variables.variable_name_2+"\nLaptop#"+current.variables.variable_name_3; //and so on.






Hi Sharique, ok I am trying your script in the Client Script of the Catalog item