- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 12:30 AM
Hello,
I have a requirement where i need to populate category for one of the catalog item on load where values are coming as URL Parameters.
I have written onLoad client script to get URL Parameters, but its not working in portal.
Onload URL:
/fuse?id=sc_cat_item&sys_id=34b896be1b6320104c6a54ea234bcbe2&sysparm_category=Benifits
client script:
function onLoad() {
//Type appropriate comment here, and begin script below
var category=getParmVal("sysparm_category");
alert(category);
}
Do "getParmVal" will work in portal, if not is there any way to access these parameters onload of catalog item in portal?
Thanks
Akash
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 01:46 AM
Hi Akash,
I've used the following script. In the script, I'm setting the value to field named "field1" on the form.
function onLoad() {
alert("hi");
g_form.setValue('field1', getParameterValue('sysparm_category'));
function getParameterValue(name) {
var url = top.location.href;
var value = new URLSearchParams(url).get(name);
if (value) {
return value;
}
if (!value) {
try {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
value = gUrl.getParam(name);
if (typeof value == 'undefined') {
return '';
} else {
return value;
}
} catch (e) {}
}
}
}
Execution:
sp?id=sc_cat_item&sys_id=<sys_id of form>&sysparm_category=Benifits
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 03:42 AM
Thanks for your help, Its working now.