Issues passing URL parameter from Workspace UI action to UI Page HTML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2025 09:18 AM
As the title says, I am trying to pass a URL parameter from my UI action to a UI page. I had this configured for a standard UI action on a standard form which was working fine, however I now need to configure it to work on a UI action in workspace which doesn't seem to work.
I have confirmed that the parameter is being set and is shown in the URL. I have added logging to my UI page, and no matter what I do I can't seem to retrieve the sys_id in the HTML of the UI page. I can successfully retrieve the parameter via the UI page client script. Below is the HTML of my UI page and the UI action workspace client script, can anyone advise if there is something I am doing wrong? I have come across lots of similar posts on the forums and it doesn't seem to be clear as to the solution.
UI Action workspace client script:
function onClick(g_form) {
//open UI page
var ui_page_id = '743e9c10831f5a107de6b2b5eeaad38a';
g_modal.showFrame({
url: '/ui_page.do?sys_id=' + ui_page_id + '&sysparm_authUser=' + g_form.getValue('caller'),
title: getMessage("User PIN Verification"),
size: 'md',
height: 500
});
}
UI Page HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!--<j:set var="jvar_authenticationUser" value="${RP.getWindowProperties().get('sysparm_authUser')}" />-->
<g2:evaluate var="jvar_getUserDetails" jelly="true">
<!--var userId = jelly.jvar_authenticationUser;-->
var userId = RP.getParameterValue('sysparm_authUser');
gs.log("Return userId: " + userId);
var grUser = new GlideRecord("sys_user");
grUser.addQuery("sys_id", userId);
grUser.query();
grUser.next();
grUser;
var userName = grUser.name;
var userSys = grUser.sys_id;
</g2:evaluate>
</j:jelly>
In the above, the logging returns "Return userId: ", the userId variable is blank and is where I wish to retrieve and utilise the sysparm_authUser from the ui action. Any help would be very much appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2025 09:24 AM
Try the below instead of RP.getParameterValue
var urlParams = new URLSearchParams(window.location.search);
var userId = urlParams.get("sysparm_authUser");
Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2025 09:33 AM
Hey @SumanthDosapati
Thanks for responding. I have tried adding this inside the <g:evaluate> tag however it errored. I added some logging and can see the error returned is "ReferenceError: "URLSearchParams" is not defined."
Rich

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2025 09:46 AM
hmm.. URLSearchParams is a javascript function but ServiceNow didnt support it.
May be you can try below manual approach to get URL.
function getParameterByName(name) {
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(window.location.href);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
var userId = getParameterByName('sysparm_authUser');
gs.log("User ID from URL:", userId);
Try this and let me know if it works. (i haven't tested it)
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi Sumanth,
I'm facing the same issue as the author.
I tried your approach but its not working.
I tried every method i can think of to fetch the URL in the HTML part but without success.
I can do the parsing easily after.
Thanks,
Milen