I need to update the short description of RITM from the information present on RITM itself.

pandeyved
Tera Contributor

Hi All,
Let's say I have made a request with "abcd" catalog. This "abcd" catalog has "xyz" variable as question whose answer I have given as "test".

When I am running this script in Background Script, 

It is updating the Short Description of RITM as: 

g.cat_item.name-g.variables.variable_name.display_value

 

But my expectation is this:

abcd - test(according to above defined scenario).

 

Script:

var val = "";
var arr = ["g.cat_item.name","-","g.variables.variable_name.display_value"];
var g= new GlideRecord("sc_req_item");
g.addQuery('sys_id','7077e4b01bdcf918aa6ffd949b4bcba7');
g.query();
if(g.next())
{
gs.info(g.number);
for(var i=0;i<arr.length;i++)
{
gs.info(arr[i]);
val = val+ arr[i];
}
gs.info(val);
g.short_description = val;
g.update();
}

Pls Assist

Thanks

7 REPLIES 7

SANDEEP28
Mega Sage

@pandeyved Use below code

Put you actual variable name instead of "xyz" in below code. 

 

var grReuqestItem = new GlideRecord("sc_req_item");
if (grReuqestItem.get('7077e4b01bdcf918aa6ffd949b4bcba7'));
{
gs.info(grReuqestItem.number);
grReuqestItem.short_description = grReuqestItem.cat_item.name + ' - ' + grReuqestItem.variables.xyz.getDisplayValue();
grReuqestItem.update();
}

 If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !! 

Hi @SANDEEP28 
Thanks
Yes I do know that I need to add variable name.
But my requirement is to pass from Array, not directly.
pls assist.

SANDEEP28
Mega Sage

@pandeyved What is your actual requirement ? Why are you taking variable names in array ? 

@SANDEEP28 

Actually, in my case, the values are stored in JSON Format, So I am parsing the JSON and storing it's value in array, then from there I am trying to print the values.

 

Like this:

{"short_description":"current.item.name,-,current.variables.variable_name.display_value"};

 

so  I will parse it and store it in an array by splitting it with comma. so the end result of short description should be:

Catalog Item name - Variable Value filled by user while making request.

 

Pls help thanks