Get all variable name apart from one variable set

lucky24
Tera Contributor

Hi Team-

I have one variable set and some other variables on catalog item and we have ui action from which we are converting task to incident and all variable should be copy in incident .

But I don't want to include  variable of particular variable set . 

I have below code to get all variable name but where I need to change, please help me

 

var arr = [];
var ritm = new GlideRecord('sc_req_item');
ritm.get('sys_id', current.request_item);
var variables = ritm.variables.getElements();
for (var i = 0; i < variables.length; i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if (label != '' && value != '') {
arr.push(label + " : " + value + "");
}
}

 

Regards,

Lucky

1 REPLY 1

Community Alums
Not applicable

@lucky24 -

 

  1. Note down the Variable Question label which we do not want to include in incident in our case we will take label as “donot_include_me”
  2. And add that in if condition as below (highlighted in cyan color)
  3. var arr = [];
    var ritm = new GlideRecord('sc_req_item');
    ritm.get('sys_id', current.request_item);
    var variables = ritm.variables.getElements();
    for (var i = 0; i < variables.length; i++) {
    var question = variables[i].getQuestion();
    var label = question.getLabel();
    var value = question.getDisplayValue();
    if (label != 'donot_include_me' && label != '' && value != '') {
    arr.push(label + " : " + value + "");
    }
    }
  4. It should omit that unwanted Variable.