- 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:07 AM
@Sandeep Rajput @Viraj Hudlikar inputs please.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- 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:11 AM
you can use this script to get all the variables for RITM, remember to enhance it for MRVS
I assume you are using UI action on RITM for this so current object is for RITM
also inc is the GlideRecord object for incident
var variables = current.variables.getElements();
var str = '';
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
var variableLabel = question.getLabel();
var variableValue = question.getDisplayValue();
str = str + variableLabel + ' - ' + variableValue + '\n';
}
inc.short_description = str;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 05:43 AM
I tried but how to use inc object here because I glide it from Script Include and this is what I have on UI Action
function convertRecord() {
var usrResponse = confirm('Are you sure you would like to proceed?');
if (usrResponse) {
var variables = current.variables.getElements();
var str = '';
for (var i = 0; i < variables.length; i++) {
var question = variables[i].getQuestion();
var variableLabel = question.getLabel();
var variableValue = question.getDisplayValue();
str = str + variableLabel + ' - ' + variableValue + '\n';
}
inc.description = str;
var ga = new GlideAjax('PH_RITMToINC');
ga.addParam('sysparm_name', 'convertMyRecord');
ga.addParam('sysparm_sysId', g_form.getUniqueValue());
ga.getXMLAnswer(function(answer) {
var url = "incident.do?sys_id=" + answer;
g_navigation.open(url, '_blank');
});
}
}