- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2025 11:16 AM
Hello experts,
When clicked on a catalog item url from esc portal, it is opening as a below link
Is there any way by which we can extract the short_descripton value from the URL itself highlighted in yellow via any catalog client script. plz help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2025 12:34 PM
Hi @Deepika54 ,
Here is a catalog client script that runs onLoad extracts the short_description value from the URL:
function onLoad() {
var short_description = getParmVal('short_description'); //URL parameter
if (short_description) {
g_form.setValue('variable_name', short_description); //Set Variable
}
}
function getParmVal(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]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2025 12:34 PM
Hi @Deepika54 ,
Here is a catalog client script that runs onLoad extracts the short_description value from the URL:
function onLoad() {
var short_description = getParmVal('short_description'); //URL parameter
if (short_description) {
g_form.setValue('variable_name', short_description); //Set Variable
}
}
function getParmVal(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]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2025 09:11 PM
you are the best
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
you can achieve this without RegEx and use OOTB Class URLSearchParams
function onLoad() {
var url = top.location.href;
var shortDescription = new URLSearchParams(url).get("short_description");
alert(shortDescription);
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
