- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 09:06 AM
Hello Experts,
I have a widget, in (icon link)widget, I have provided the URL of the record producer in the widget at the server-side, so after clicking on this it is redirecting to the Record Producer ABC.
like : data.href=gs.getProperty('glide.servlet.uri')+gs.getProperty('Portal suffix')+"sys_id of record producer";
but I want to send some extra parameter from this URL like '&sysparm_dept=XYZ'
and want to capture this in the record producers variable.
so if the variable contains "XYZ" I want to populate some more variables using client script.
Can you please help me with the same?
Please share the thoughts and how to achive this ? which way is a better way to achieve this?
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 09:11 AM
Hi there,
For Service Portal, you could add an onLoad Catalog Client Script to your Record Producer. onLoad Catalog Client Script which code like for example:
function onLoad() {
var value = getParameterValue('sysparm_test');
if(value) {
g_form.addInfoMessage(value);
}
}
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
In this case, I just added to the URL:
This would give me:
The example is just with a g_form.addInfoMessage. Though obviously you could use g_form.setValue etc..
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 09:11 AM
Hi there,
For Service Portal, you could add an onLoad Catalog Client Script to your Record Producer. onLoad Catalog Client Script which code like for example:
function onLoad() {
var value = getParameterValue('sysparm_test');
if(value) {
g_form.addInfoMessage(value);
}
}
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
In this case, I just added to the URL:
This would give me:
The example is just with a g_form.addInfoMessage. Though obviously you could use g_form.setValue etc..
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 10:01 PM
Hello Mark,
Thank you for the quick reply,
But after clicking on the URL
Server script : data.href=gs.getProperty('glide.servlet.uri')+gs.getProperty('Portal suffix')+"sys_id of record producer"+'&sysparm_test=hello';
i can't see the 'sysparm_test=hello' additional parameter in the URL after opening.
So in the OnLoad script, I am not getting any value.
Can you please guide me on the same?
Thanks.