- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 11:42 AM
I have a requirement on portal, where we need to copy the RITM for a specific catalog item's RITM. And when they click on the RITM it should open the new catalog item to auto populate the variable values from the original RITM.
I have updated the widget to show the copy button and then it will redirect to empty catalog item, but not able to find a solution to auto populate the variable values from the original RITM to the new catalog form opened.
I want this to open in a new catalog form, so the users can edit and submit the accordingly to create request from portal.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 11:46 AM
Hello,
If you have to redirect to the item page, you have to construct an URL,
1. encode the RITM sys_id in the URL and in the catalog item
2. have an onLoad client script to get the parameter from URL.
3. the parameter will hold the old RITM sys_id, query the RITM and get the values using GlideAjax.
4. Construct a JSON from server side and pass it to client and set the values in the fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 12:21 PM
First you have to construct the URL with the RITM sys_id encoded.
<Your URL>+'old_ritm=' + current.sys_id
Here, you can define any parameter, I have given it as 'old_ritm' and if you are using any variables query the RITM, instead of current you can mention that. Now you have the URL and when user click on the URL, they will redirect to the portal page where they see the item with empty variables.
Now a client script needs to be created on the item. it should be onLoad of the item and client script should look for the parameter in the URL,
For native view, you can use the following,
var url = new GlideURL(window.location.href);
var myParam = url.getParam('old_ritm');
For portal,
function getParameterByName(name) {
var url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&'); // Escape any special characters
var regex = new RegExp('[?&]' + old_ritm + '(=([^&#]*)|&|#|$)');
var results = regex.exec(url);
if (!results) return null; // If parameter not found
if (!results[2]) return ''; // If parameter is empty
return decodeURIComponent(results[2].replace(/\+/g, ' ')); // Decode and return the parameter value
}
If the scripts return values then it means the URL has the parameter. Since you given the sys_id in the URL parameter, you have the old RITM sys_id with you. You can use the usual glideajax script to get the values from the old RITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 07:50 PM
I have written this onLoad client script -