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

thanks again!!


tltoulson,



I'm running into an issue with this. If an email comes to a support group and they click on the link to go directly to the catalog task, they are taken to the ESS homepage instead. This shouldn't happen. Do I need to update the URL?


This is what it looks like:


<font color="#ff0000">For INTERNAL access:</font> <font color="#0000ff">${URI_REF}</font>


The ${URI_REF} tag is replaced with the non-CMS link when it is processed into an email.   So when your scripts/login rules get a hold of the URL, it will redirect to the CMS homepage.   There are two ways to fix this:



1.   Make your redirect script 'smarter'.   This is the harder one but requires only changing the one script.


2.   Change every ${URI_REF} in your email templates to a CMS friendly link.


What do you mean, smarter? Do a check to see if they are coming from an email link somehow?


Basically, you could use the document.referrer to figure out which URL the user was trying to reach (in this case, via email) and route them to the appropriate CMS version of the page.   For example:



var cmsUrl,


sysId,


cmsBase = 'instancename.service-now.com/ess/';



if (document.referrer.indexOf('incident.do') != 0) {


sysId = ''; // Use a regex or other string parsing to find the Sys Id of the incident from the referrer URL


cmsUrl = cmsBase + 'incident_detail.do?sysparm_document_key=incident,' + sysId;


}



You could then perform a similar check for the other record types used in the CMS.   Basically, this script is saying "if you want to route to the ITIL site incident.do, then you need to go to cmsUrl for the CMS version of the page."   Of course, you would have to properly plug this snippet into the overall redirection script you are already using.   Let me know if you need further help on that.