Get all variable name apart from one variable set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 02:00 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 06:12 AM
@lucky24 -
- 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”
- And add that in if condition as below (highlighted in cyan color)
- 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 + "");
}
} - It should omit that unwanted Variable.