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 10:51 AM
@pandeyved Use below code
You need to use getElement() method to do dot walk for fields.
You can modify it as per your requirement.
var arr = ["cat_item.name","variables.Additional_software_requirements"];
var grReuqestItem = new GlideRecord("sc_req_item");
if (grReuqestItem.get('9ebe21302f50311047e3bcb62799b667'));
{
grReuqestItem.short_description = grReuqestItem.getElement(arr[0]) + ' - ' + grReuqestItem.getElement(arr[1]);
gs.info(grReuqestItem.short_description);
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-26-2023 02:04 AM
Thanks,
But in my case:
grReuqestItem.short_description = grReuqestItem.getElement(arr[0]) + ' - ' + grReuqestItem.getElement(arr[1]);
I am not using grRequestItem here in this line.
In my case : the object User will return in JSON which is "current".
That is why I am passing the object also in array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 02:13 AM
arr[1] will return sys_id I think.