I need to update the short description of RITM from the information present on RITM itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 12:58 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 03:42 AM
@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 !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 04:40 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 05:25 AM
@pandeyved What is your actual requirement ? Why are you taking variable names in array ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 06:34 AM
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