- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2020 11:07 PM
I need to generate the current user's name and email address in the URL and every time the hyperlink takes you to that URL the name and email address should dynamically reflect as that of the current user. Please help with the correct URL code. This dynamic generation needs to happen on the click of a menu item on Service Portal.
URL is ->
https://alstom-webchat.managed.computacenter.com/Webchat/webchat-flow.htm?name=Paul Meachen &emailaddress=Paul.Meachen@customer.com&locale=en-GB&reason=GNRL&division=x&telephone=6228006119&log...
where current user's name and email is show. This needs to change every time for the current logged in user.
This link will open up when a menu item on the portal under a page is clicked. for which I have done the below config that when the Webchat link is clicked upon the URL should hit dynamically.
URL I wrote in menu item HREF is - https://alstom-webchat.managed.computacenter.com/Webchat/webchat-flow.htm?un=${gs.getUserName()}&${gs.getEmail()}" target="_blank
The above is not working. Please help me with the correct code.
Thanks in advance Community,
Utkarsha S
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 01:13 AM
Hi Utkarsha,
you need to get the details by querying sys_user table with logged in user;
sample script below
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
var url1 = "https://alstomwebchat.managed.computacenter.com/Webchat/webchat-flow.htm?name=" + gr.name + "&email=" + gr.email + "&user_name=" + gr.user_name + "&location=" + gr.location.name + "&department=" + gr.department.name + "&mobile_phone=" + gr.mobile_phone + "&first_name=" + gr.first_name;
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 03:49 AM
Thanks a lot Ankur, your script worked. I edited it a bit further and it worked well for the button function.
Though still this is not happening through menu item. Can't we have the dynamic URL population happen through a menu item ?
Utkarsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2022 12:53 PM
Where would this need to placed or how can I make the call to create that URL.
Hi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 01:24 AM
just confirming here, you started the question about the menu item , and you were passing the value in url there ? did you change the requirement or its different question ?
anyway you can refer the below blog here and see if predefined method works here or not. if it is not working then do the glide record on user table to access the respective column details.
https://www.servicenowguru.com/scripting/user-object-cheat-sheet/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2020 02:16 AM
I need to do this via a menu item too where in I am using a menu item of type catalog item and linking the page "sc_cat_item" to it and made a new catalog item which has to re-direct to this dynamic URL - can you help with that approach too ?
Utkarsha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2020 03:05 AM
whats the issue are you facing with the approach which i suggested earlier ?
eg:
https://alstom-webchat.managed.computacenter.com/Webchat/webchat-flow.htm?un=javascript:gs.getUserName()