Auto-populate a Record Producer with data from other Record Producer via redirect

JayCar
Tera Contributor

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?

2 REPLIES 2

Abhay Kumar1
Giga Sage

@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.

Amit Verma
Kilo Patron
Kilo Patron

Hi @JayCar 

 

You can refer below blog which might be helpful for your requirement :

https://www.servicenow.com/community/developer-blog/3-ways-to-populate-values-in-servicenow-via-the-...

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.