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

Sorry, just noticed a flaw.   It should read:



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)



1. g_user.hasRole('ESS_IT_User') => If the user is a ESS_IT_User


  AND


2. document.URL.indexOf('ess') == -1 => If the user is accessing the page accessed is not a CMS page


  AND


3. top.document.referrer.indexOf('ess') == -1 => If the user is not redirected from the CMS, ess will not appear in the URL


  AND


4. top.document.referrer.indexOf('navpage.do')!=-1) => If the user is not redirected from an email or direct link, navpage.do will not appear in the URL


Ok - I see what it's doing. However, IT users are no longer brought to the ESS site by default. When they click on a link in an email, they are brought to the ESS homepage -- something needs to be reversed, I think. Perhaps we can do this in private messaging since this post has become quite large?


I swapped the == to != for the ess calls:



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) {



This works when clicking on a link - but IT users aren't brought to the ESS site now.


Hello Travis,



Grate help ..


It shows one error on my case . Once I activate this script for next login the site take me always to the ESS login page. If am an admin or any other role first it taking me to the ESS portal then if I manually correct the URL to normal UI it takes me there. On the case of No Role user this is work perfectly fine.   Any more setting there I need to add so user with role never take ESS login page by default?


I am trying to use this global ui script method that you suggested. We use SAML 2.0 single sign on and this is the only way we have discovered to have our ITIL users and ESS user to redirect to the CMS site. On the CMS site we have a link for the ITIL user to allow them to go back to the old site if needed. We have discovered some cascading issues:


1. Once the ITIL user is back in the original site, if they click on the magnifying glass on a reference field to view the list - it opens it up and then reroutes that window to the CMS site.


2. The homepages on the original site are now blank.



Have you or anyone experienced or discovered a fix to these issues?