- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 05:05 AM
Hi Team,
There is a requirement for me to create an UI Action which converts RITM to INC.
So, I created an UI Action on RITM table and a Script Include.
Now the ask is to copy all the variables of the RITM to the description of the Incident.
I am trying something below:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 05:10 AM
Steps:
- Extract the label and display_value from allVARS.
- Format them as a readable string.
- Set this formatted string as the description of the Incident.
var allVARS = new global.GlobalServiceCatalogUtil().getVariablesForTask(ritm, false);
var descriptionText = '';
for (var i = 0; i < allVARS.length; i++) {
var label = allVARS[i].label;
var value = allVARS[i].display_value;
descriptionText += label + ': ' + value + '\n'; // Formatting for better readability
}
// Assuming 'incident' is the newly created incident record
incident.description = descriptionText;
incident.update();
Please mark helpful/ Accept solution if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 05:14 AM
Hello @DB1
Check this article
(1) Convert an RITM to an Incident - ServiceNow Community
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 05:36 AM
Hello @DB1 ,
You can below code to show RITM variables on description of incident:
var Num = current.sys_id;
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', Num);
gr.query();
if(gr.next()) {
//store the ritm number and variable information if required
var ritmNum = gr.getValue('number');
var itemName = gr.getDisplayValue('cat_item');
var names = Object.keys(gr.variables);
var string = '';
for (var i = 0; i < names.length; i++) {
//get the all variables and store.
var variable = gr.variables[names[i]];
if (variable.getLabel() && variable.getDisplayValue()) {
//store the all variables in formated form.
string += variable.getLabel() + ": " + variable.getDisplayValue() + '<br>';
}
}
//set the ritms and variable information in description field of incident
inc.description+= '<p style="font-size:11pt;"><b>' + 'Requested Item: ' + ritmNum + ' - ' + itemName + '</b>' + '<br><br>';
inc.description+= string + '<br><br><br></p>';
}