Copying variable values of RITM to a record Producer via UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 02:43 AM
Hi All,
I have a requirement to create a button on RITM form that converts the current RITM to an Incident.
I am trying to redirect the UI action to a record producer as below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 02:51 AM
include those RITM variables as URL parameter and then use onLoad catalog client script to fetch and set on catalog form
Redirect from a UI Action to a Catalog Item and set default values
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-26-2025 03:05 AM
try this
var ritmNumber = g_form.getValue('number');
var shortDescription = g_form.getValue('short_description');
var impact = g_form.getValue('impact'); var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=62fb775337fasergfgtne012' + '&sysparm_variables=ritm_number=' + encodeURIComponent(ritmNumber) + '^short_description=' + encodeURIComponent(shortDescription) + '^impact=' + encodeURIComponent(impact);
window.location = url;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 03:13 AM
Hi @DPrasna
As per understanding your goal is to capture the variable values from the RITM and pass them to the record producer, which will then create an Incident with those values pre-filled.
If yes, then first, you'll need to grab the values of the variables associated with the current RITM.
You'll create a URL to redirect the user to the record producer form (a Service Catalog item). You can pass the values of the variables via query parameters in the URL. Record Producers can be pre-populated using these parameters.
The record producer can then take these query parameters and use them to set the values for the corresponding variables on the form.
function convertRITMToIncident() {
// Get the current RITM variables
var issueType = g_form.getValue('u_issue_type');
var priority = g_form.getValue('u_priority');
var description = g_form.getValue('u_description');
var ritmNumber = g_form.getValue('number');
// Construct the URL for the Record Producer with the pre-populated values
var recordProducerUrl = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=62fb775337fasergfgtne012' +
'&u_issue_type=' + encodeURIComponent(issueType) +
'&u_priority=' + encodeURIComponent(priority) +
'&u_description=' + encodeURIComponent(description) +
'&ritm_number=' + encodeURIComponent(ritmNumber); // Pass RITM number if needed
// Open the Record Producer in a new window
window.open(recordProducerUrl);
}
then you need to ensure that the record producer form is set up to accept these query parameters. You can do this by creating a Catalog Client Script (onLoad) in the record producer.
function onLoad() {
// Check if the query parameters exist
if (g_request.getParameter('u_issue_type')) {
g_form.setValue('u_issue_type', g_request.getParameter('u_issue_type'));
}
if (g_request.getParameter('u_priority')) {
g_form.setValue('u_priority', g_request.getParameter('u_priority'));
}
if (g_request.getParameter('u_description')) {
g_form.setValue('u_description', g_request.getParameter('u_description'));
}
if (g_request.getParameter('ritm_number')) {
g_form.setValue('u_ritm_number', g_request.getParameter('ritm_number')); // You can set this value to a hidden field if needed
}
}
I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 06:53 AM
Hi All,
I tried in different ways but none worked.
@Rajesh Chopade1 @Ankur Bawiskar @sravya chipilla
function onLoad() {
if (g_request.getParameter('opened_by')) {
g_form.setValue('opened_by', g_request.getParameter('opened_by'));
}
if (g_request.getParameter('priority')) {
g_form.setValue('priority', g_request.getParameter('priority'));
}
if (g_request.getParameter('description')) {
g_form.setValue('description', g_request.getParameter('description'));
}
}