Redirect ITIL users to CMS

Blair5
Tera Guru

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?

1 ACCEPTED SOLUTION

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.


View solution in original post

63 REPLIES 63

Hmmm - I'm not sure we want to route support teams to an incident via the CMS view. If I understand this correctly, this script would direct the user to the CMS page no matter what.


Well, it would be a matter of building up the rule sets in the script.   At this point, the script checks roles, the document accessed and the referrer.   So the question is, how should clicking an email link differ from the existing rules.



User RolesDocument AccessedReferrerAction
AdminAnyAnyNo Redirection
No RolesITILAnyRedirect to CMS Homepage
Has Any RoleITILAny Non-CMSRedirect to CMS Homepage
ELSEELSEELSENo Redirection


Your rules may be slightly different, but those are from the script that was the accepted answer.   So if an ITIL user clicks a link in an email that goes to the ITIL site, what should happen?   If a non ITIL user clicks a link in an email that goes to the ITIL site, what should happen?



From there, we can determine the best solution.


The rules you have outlined are correct (basically - instead of 'no role' it would be != ESS_IT_User role and Has any role would be == ESS_IT_user)



If an ITIL user clicks a link in an email, they should be directed to the ITIL site. If a non-ITIL user clicks a link in an email, they should go to the CMS.


Ok, so lets tackle these two new scenarios:



1.   ITIL user clicks an email link, user should see the ITIL site


2.   Non-ITIL user clicks an email link, user should see the CMS site



Scenario 1 does not require any redirect, you want to display exactly the link that they clicked.   Right now though, because it is an ITIL user, accessing an ITIL site document, and its referrer is not the CMS, the third rule in the table in my previous comment is triggered, redirecting the user.



To complete Scenario 1, we need to change that rule to push it to the Else rule.   You could add to the if statement for that rule by saying if ((document.referrer.indexOf('ess') != -1 || document.referrer.indexOf('navpage.do') != -1)).   Email links seem to use instancename.service-now.com/navpage.do as the referrer (test for cross browser support).   This has a side effect that if an ITIL user navigates directly to a specific incident by url, the ITIL user will see the ITIL site and not the CMS.



To complete Scenario 2, you would have to use the URL splicing I mentioned in an earlier post.   Otherwise the user would simply redirect to the CMS homepage and not the CMS version of the Incident for instance.


I have a meeting tomorrow morning with the people who requested this enhancement. I need to verify that this is the behavior they want to achieve before I start down this road. I will keep you posted and thank you so much for your help!