- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2014 10:47 AM
We already have login rules in place to redirect non-roled users to our CMS. However, we would like to route all users to the CMS -- how? Also, for itil roled users, we would like to have them click on a link from within the CMS and be routed back to the itil view.
For non-roled users, we have a homepage defined for them with a content block that redirects them to the CMS site. We don't want to do that for itil people because we don't want them to be rerouted back to CMS if this click on the link to go to the itil site. Any suggestions?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2014 07:07 AM
Excellent point, yes, if the ITIL user changes their home page, they would bypass your script. A better alternative is to create it as a global UI Script. Try this one out:
UI Script
Name: ESS Redirect
Active: True
Description: Redirects users to the ESS site
Global: True
addLoadEvent(function() {
if (g_user.hasRole('admin') {
// Do nothing if user is admin, this is to allow testing of the script without risk
}
// If user has no roles and they are on a non ESS page
else if (!g_user.hasRoles() && document.URL.indexOf('ess') == -1) {
// Redirect to ESS
window.location = 'https://instancename.service-now.com/ess';
}
// If user has roles, they are on a non ESS page and they were not referred from the ess site
else if (g_user.hasRoles() && document.URL.indexOf('ess') == -1 && top.document.referrer.indexOf('ess') == -1) {
// Redirect to ESS
window.location = 'https://instancename.service-now.com/ess';
}
});
NOTE: Global UI scripts will run on both ITIL site and ESS site. This is why the document.URL.indexOf('ess') is necessary, it prevents redirection from the ESS site to the Ess site.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2014 11:13 AM
Travis,
As per my morning meeting, this is something that I will pursue. I will probably dive into this tomorrow and will most likely need your assistance.
Thank you again for all your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2014 08:37 AM
I added the 'if((document.referrer...' to line 21. I haven't tested because I am thinking that's not even right. Should I add it within the if statement of line 18?
As far as scenario 2, that would probably be within the if statement of line 13?
Or, should these 2 scenarios be a separate function?
addLoadEvent(function() {
try{
var thisHost = window.location.origin;
if (!thisHost)
thisHost = window.location.protocol+"//"+window.location.host;
if (g_user.hasRole('admin')) {
// Do nothing if user is admin, this is to allow testing of the script without risk
}
// If user has no roles and they are on a non ESS page
else if (!g_user.hasRole('ESS_IT_User') && document.URL.indexOf('ess') == -1) {
// Redirect to ESS
window.location = thisHost + '/ess';
}
// If user has roles, they are on a non ESS page and they were not referred from the ess site
else if (g_user.hasRole('ESS_IT_User') && document.URL.indexOf('ess') == -1 && top.document.referrer.indexOf('ess') == -1) {
// Redirect to ESS
window.location = thisHost + '/ess';
}else if((document.referrer.indexOf('ess')!=-1 || document.referrer.indexOf('navpage.do')!=-1))
window.location = thisHost + '/ess';
}
catch (err) {
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2014 12:31 PM
Actually, for Scenario 1, you can just append it to the else if on line 18 as I have done below. That way, if they were referred from the ess site link OR email/direct url link, that rule will be ignored and they will not be redirected to ESS (the unwritten/hidden 'else' case of the script causes no redirection / no action).
For Scenario 2, yes, you would add the if logic within the else if statement on line 13. The basic logic is:
- If user is admin, then do not redirect
- Else if user is not ESS_IT_User and on a non-ESS page
- If the user is on an incident.do page, then redirect to ESS friendly incident page
- Else If the user is on a request.do page, then redirect to ESS friendly request page
- etc
- Else redirect to ESS homepage (the final else, in other words if a suitable ESS page can't be found)
- Else if user is a ESS_IT_User and on a non-ESS page and they were not referred by either the ESS site, Email, or direct url link, then redirect to ESS page
There is no need for a separate function in this case because ESS_IT_Users would never redirect to the ESS site if they tried to get to incident.do/sys_id=somesysid for instance. So only non ESS_IT_Users would use the functionality. If you had multiple cases using the same incident/request/change routing logic, then it would make sense to use a separate function.
Does that help?
addLoadEvent(function() {
try{
var thisHost = window.location.origin;
if (!thisHost)
thisHost = window.location.protocol+"//"+window.location.host;
if (g_user.hasRole('admin')) {
// Do nothing if user is admin, this is to allow testing of the script without risk
}
// If user has no roles and they are on a non ESS page
else if (!g_user.hasRole('ESS_IT_User') && document.URL.indexOf('ess') == -1) {
// Redirect to ESS
window.location = thisHost + '/ess';
}
// If user has roles, they are on a non ESS page and they were not referred from the ess site OR either email or direct url
else if (g_user.hasRole('ESS_IT_User') && document.URL.indexOf('ess') == -1 && (top.document.referrer.indexOf('ess') == -1 || top.document.referrer.indexOf('navpage.do')!=-1))) {
// Redirect to ESS
window.location = thisHost + '/ess';
}
catch (err) {
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2014 01:23 PM
As a first pass, it doesn't work as it should. I will have to look more into it tomorrow morning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2014 08:24 AM
Travis,
Could you help me understand what lines 17-19 are doing? It seems like the if statement is not correct.