- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2023 11:13 AM
I need to parse the URL for a catalog item. I am using the following onload script but get browser error.
Can someone please help me overcome this problem. My experience with JavaScript is limited so collaboration will be helpful.
function onLoad() {
//Populate the variables with the parameters passed in the URL
//Use the 'getParmVal' function below to get the parameter values from the URL
var cat = getParmVal('sys_parm');
if(cat){
g_form.setValue('my_category_variable',cat);
/ }
if(comments){
g_form.setValue('my_comments_variable',comments);
}
}
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2023 10:45 PM - edited ā03-04-2023 10:46 PM
Based on what I'm guessing is wanted, it would be:
function onLoad () {
var getParmVal = getSearchParams();
var cat = getParmVal('sys_parm');
var comments = getParmVal('???');
if (cat) {
g_form.setValue('my_category_variable', cat);
}
if (comments) {
g_form.setValue('my_comments_variable', comments);
}
}
function getSearchParams () {
var url = new URL(self.location.href);
var searchParams = url.searchParams;
return function get (name) {
return searchParams.get(name)
};
}
But the parameter name (sys_parm) doesn't seem right and I don't know the parameter name for comments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-05-2023 09:09 AM
You're welcome š
Thanks for marking the solution!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-19-2025 04:47 PM
Hello
I'm having a requirement to Create Standard Change from RITM and set Change parent as RITM reference.
I did created below UI action which takes me to the standard change templates landing page,
var url = new StdChangeUtils().getURLForTask(current, 'rfc');
url += '&ritm_sys_id=' + current.sys_id;
action.setRedirectURL(url);
In this script, i am injecting ritm_sys_id into the URL and trying extract it & populate the parent field on the change form with the RITM reference.
However the below onLoad client script is not working as expected.
if (!gForm.isNewRecord()) return;
try {
var fullUrl = window.location.href;
var match = fullUrl.match(/[?&]ritm_sys_id=([0-9a-f]{32})/);
if (match && match[1]) {
var ritmSysId = match[1];
gForm.setValue('parent', ritmSysId);
}
} catch (e) {
console.error('Error extracting ritm_sys_id:', e);
}
Kindly suggest on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-20-2025 04:03 AM
A reason for that not working is explained in the annotation on Client Script and even Catalog Client Script forms:
Disclaimer: there might be other errors too, have not analyzed the full script, stopped at windows..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2023 01:36 PM
Hi,
Make sure isolate script should be false in client script and UI Type should be All.
Also in the script, below line has extra slash(/)
if(cat){
g_form.setValue('my_category_variable',cat);
}
please make the above changes and try.
thanks,
Faizeal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2023 01:43 PM
Option "Isolate script" does not apply to Portal.