Redirect to a record producer with a sysparm in URL from Service Portal page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 02:22 AM
Dear community,
I've got a situation where my customer wanted to have a UI action to create an incident in case a user is dissatisfied with the solution of a RITM.
So, I've managed to make it running on platform - I've got a UI action redirecting to a record producer with a RITM number as a sysparm. Then, the record producer have a read-only field with a default value of that number in sysparm. Creating the incident as such is handled with a Flow.
Anyway, the customer is looking at their RITMs from the SP view as well, especially no-role users. But these people should be able to create such complaint incidents as well without any unnecessary effort. Is there any way to make this solution working on the Service Portal please?
If not, could you please try to suggest me a different approach?
There should be a button (as you can see in the picture) which takes the user to a record producer. I need to somehow parse the RITM number from the RITM form to that field on my record producer.
Thank you for any help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 02:38 AM
Hello @matej_h,
First, you will need to modify your UI action script to check if the user is on the service portal or not, and then use the appropriate URL for the redirection. You can use the g_service_catalog.isCatalog() method to determine if the user is on the service portal, and then use the g_service_catalog.getRecordProducerURL() method to get the URL for the record producer on the service portal. You will also need to pass the RITM number as a query parameter in the URL, using the sysparm_query key. For example, your UI action script might look something like this:
function onClick() {
// Get the current RITM number
var ritmNumber = g_form.getValue('number');
// Check if the user is on the service portal
if (g_service_catalog.isCatalog()) {
// Get the URL for the record producer on the service portal
var url = g_service_catalog.getRecordProducerURL('your_record_producer_sys_id');
// Append the RITM number as a query parameter
url += '&sysparm_query=ritm_number=' + ritmNumber;
// Redirect to the record producer on the service portal
window.location = url;
} else {
// Get the URL for the record producer on the platform
var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=your_record_producer_sys_id';
// Append the RITM number as a query parameter
url += '&sysparm_query=ritm_number=' + ritmNumber;
// Redirect to the record producer on the platform
window.open(url);
}
}
Second, you will need to modify your record producer script to get the RITM number from the query parameter and set it as the default value for your read-only field. You can use the RP.getParameterValue() method to get the query parameter value, and then use the RP.setDisplayValue() method to set the display value for your field. For example, your record producer script might look something like this:
(function() {
// Get the RITM number from the query parameter
var ritmNumber = RP.getParameterValue('ritm_number');
// Set it as the default value for your read-only field
RP.setDisplayValue('your_read_only_field', ritmNumber);
})();
Hope this helps.
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 02:51 AM
Hi @SwarnadeepNandy!
Thank you so much for such a fast reply with the solution proposal. I've tried to modify my solution with your snippets but when I click my button, the instance brings me back to previous page and nothing happens at all.
When the button is clicked on SP, I only get a green box on top of the page 'Record updated' and nothing happens either.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 04:00 AM - edited 08-17-2023 04:02 AM
I haven't tried the code in my instance, maybe if you can let me know what the errors are I can help with code modifications.
And did you updated the code with the relevant sys_id s or you directly copy pasted the code?
Best Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 04:13 AM - edited 08-17-2023 04:18 AM
Yep, I adapted the code to my instance sys_ids of course.
As I already mentioned,
On Platform: clicking the button redirects me to previous page.
On SP: clicking the button just brings a green box on top of the page saying 'Record Updated,' no redirection is happening. No real change happens anywhere.
Console output files named accordingly.