Auto-populate a Record Producer with data from other Record Producer via redirect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2024 02:02 PM
Hi, is it possible to redirect a user in a record producer in portal to another record producer and have the variables auto-populated on the previous form without saving the previous one? I'm not sure if this is possible since we are not saving any data, but is it possible using URLs?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2024 06:50 PM
@JayCar Yes, it is possible to redirect a user from one record producer to another in ServiceNow's Service Portal and pass variables between them using URL parameters.
Create a client script and place it in section of client script of first record producer, script should be something like this:
function redirectToSecondProducer() {
// Get the values from the current record producer variables
var variable1 = g_form.getValue('variable_name1'); // Replace with your actual variable name
var variable2 = g_form.getValue('variable_name2'); // Replace with your actual variable name
// Construct the URL for the second record producer
var redirectUrl = 'https://<instance>.service-now.com/sp?id=<second_record_producer_sys_id>'; // Replace with the actual sys_id of the second record producer
redirectUrl += '&variable_name1=' + encodeURIComponent(variable1);
redirectUrl += '&variable_name2=' + encodeURIComponent(variable2);
// Redirect to the constructed URL
window.location.href = redirectUrl;
}
// Call the function based on your specific logic (like any button click)
redirectToSecondProducer();
Hope this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2024 06:53 PM
Hi @JayCar
You can refer below blog which might be helpful for your requirement :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.