To Copy All Variables information In catalog Task description

sri24
Giga Contributor

Hello All,

After user submits the Request, I need to copy all the variables information into Description field of Catalog Task. How can i do this can anyone please help me with this.

Thanks in Advance

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";

 

}

 

}

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

 

View solution in original post

6 REPLIES 6

Ankur Swami
Tera Guru

Hi,

Write a Business Rule on the 'sc_req_item' table.

Condition: item>> Your catalog item name

 

Now paste the below code in the advanced script:

 

var variables = current.variables.getElements();

var str = '';
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
var variableLabel = question.getLabel();
var variableValue = question.getDisplayValue();
str = str + variableLabel + ' - ' + variableValue + '\n';
}

current.short_description = str;

 

Please mark correct answer if it helps.

Hello Ankur,

 I need to update catalog task description i tried with your script but no luck

Saurav11
Kilo Patron
Kilo Patron

Hello,

var grVariableRelation = new GlideRecord('sc_item_option_mtom');
grVariableRelation.addQuery('request_item', current.getUniqueValue());
grVariableRelation.addNotNullQuery('sc_item_option.value');
grVariableRelation.orderBy('sc_item_option.order');
grVariableRelation._query();

while(grVariableRelation._next()) {
	descriptionStr += grVariableRelation.sc_item_option.item_option_new.getDisplayValue() + ': ' + current.variables[grVariableRelation.sc_item_option.item_option_new.name].getDisplayValue() + '\n';
}

task.description = descriptionStr;

Hope this helps. Please mark the answer as correct/helpful based on impact.

sri24
Giga Contributor

Hello Saurav

it's not working