- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2015
12:24 PM
- last edited on
09-16-2023
11:57 PM
by
ServiceNow
I'm attempting to build a URL that will link a user to a specific record within the ITIL view of our ServiceNow instance if they have the ITIL role, or the ESS view of the same record if they do not have the role. Right now, if I were to create an INC within our instance, the following URLs would direct to the same record within the two views:
ITIL view: https://<instance>.service-now.com/nav_to.do?uri=incident.do?sys_id=<sys_id>
ESS view: https://<instance>.service-now.com/ess/incident_detail.do?sysparm_document_key=incident,<sys_id>
Both links will direct ITIL users to the respective view of the record, but they are not interchangeable for non-ITIL users. If an ESS user clicks on the ESS view link, they will be directed to the ESS view of the record; however, if they click on the ITIL link, it routes them directly to the main page of the ESS. I would like to create one URL that will direct ITIL users to the ITIL view of the record and ESS users to the ESS view of the record.
I feel like the redirector.do UI page detailed here is the key:
Content Management Security - ServiceNow Wiki
but I cannot find a way to make this UI page work dynamically with our current redirect UI script, which looks like this:
window.addEventListener('load', do_forceEssPortal(), false);
function do_forceEssPortal() {
if (typeof top.window.frames.gsft_nav != 'object') {
return;
}
if (typeof g_user == 'object') {
if (g_user.userName != 'guest' && !g_user.hasRole('itil')) {
top.window.location = '/navpage.do';
return;
}
}
if (typeof top.g_user == 'object') {
if (top.g_user.userName != 'guest' && !top.g_user.hasRole('itil')) {
top.window.location = '/ess/main.do';
return;
}
}
}
This script seems to act after a user clicks on the URL (in an email notification, for example), and then just redirects them to the ESS main page by appending '/ess/main.do' to the URI. As it stands, the issue is that I cannot find a way to get the URL string that the user clicked on order to cut the sys_id out of the string and append it to the correct URL schema, essentially replacing the '/ess/main.do' portion of this script with a URL that will automatically redirect them to the record with that sys_id. However, I'm not immediately sure this is even the best way to accomplish this.
Is there a way to get this URL information within the UI script, or possibly a better way to accomplish the same thing? I have seen these posts:
Links to ESS pages redirect to ESS homepage
How can I redirect a user with an onChange client script?
https://www.servicenow.com/community/now-platform-blog/getting-your-servicenow-urls-right/ba-p/22917... |
And while I believe they have been helpful, I have yet to find a way to create one interchangeable URL for ITIL and ESS users.
I apologize if this question is confusing or lacking in information, this will be my first foray working with redirection involving a CMS page.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2015 12:47 PM
Here's a pretty good blog post detailing when to use the different redirect methods.
Redirecting user logins - UI Scripts, Login Rules, or Installation Exits

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2015 12:47 PM
Here's a pretty good blog post detailing when to use the different redirect methods.
Redirecting user logins - UI Scripts, Login Rules, or Installation Exits
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2015 03:16 PM
That was it. document.URL allowed me to pull the URL into the UI Script and get the sys_id from it:
window.addEventListener('load', do_forceEssPortal(), false);
function do_forceEssPortal() {
if (typeof top.window.frames.gsft_nav != 'object') {
return;
}
if (typeof g_user == 'object') {
if (g_user.userName != 'guest' && !g_user.hasRole('itil')) {
top.window.location = '/navpage.do';
return;
}
}
if (typeof top.g_user == 'object') {
if (top.g_user.userName != 'guest' && !top.g_user.hasRole('itil')) {
var sysIDString = document.URL.match(/sys_id=([0-9a-zA-Z]+)/)[1];
if (document.URL.indexOf('incident')>-1){
top.window.location = 'https://<instance_name>.service-now.com/ess/incident_detail.do?sysparm_document_key=incident,'+sysIDString;
return;
}
}
}
Works just fine for creating a URL that will redirect the users to the ESS incident ticket view. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2015 01:04 PM
I used the Login Rules Brad mentions above and then I created a link to the ESS portal and added it to the Navigational Menu for the IT users so they could easily access what the end-users were seeing.