The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Redirect ITIL users to CMS

Blair5
Giga 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

tltoulson
Tera Guru
Tera Guru

Using the content block method on a homepage is a common redirection method in ServiceNow (ServiceNow mentions a similar method for redirection using a private CMS page in the wiki).   And its VERY useful might I add.



It sounds as though you are looking for a conditional redirection, though.   One possible solution for the ITIL role link, is to use the client side javascript document.referrer property (check the browsers you need to support to ensure it will work for all of course).   To accomplish this, your content block redirection would need to include script such as:



if (top.document.referrer != 'instancename.service-now.com/ess') {


    window.location.href = 'instancename.service-now.com/ess';


}



That way, if your itil users are navigating from the ess, they will not be redirected back.   Otherwise, they will be redirected.   You may need to adjust the script if you are referring from different pages (I'm not sure if the referrer property is the full URL or just the base).   Does this sound like a workable solution?



Let me know and I will provide further assistance if needed.


This is very helpful. However, I want to make sure I understand the steps to take. First, how do I set the default page behavior to have everyone route to the CMS? After that, do I add the content block to the ITIL site or the CMS site?



I can send you a screenshot of what we are trying to accomplish if that would help?



Sorry it took me so long to reply!


Not a problem!   What I was suggesting is that you can create a homepage content block for roled users the same way you have done for non-roled users for redirection.   The difference is that for roled users, you need to provide a check to see if the user is being redirected from the CMS (if they click the link).   For that check, you would use the top.document.referrer approach mentioned above.



Also you have the Login Scenarios as mentioned in the wiki but that would only cover the initial login.   It doesn't affect anything once a session is established and perhaps that is what you want.



Screenshots and anything else that covers what you currently have and are looking to accomplish would be helpful.



Kind regards,



Travis


I think I understand. The only thing though -- what if an ITIL user has their own defined homepage? Can we only add the content block to the homepage, or is there a way to add it to the header or something? I copied a screen shot below of what we are trying to accomplish. Also, I read the WIKI page you linked to and I'm not sure that we can utilize that since we use single sign on. I found the sys property for glide.login.home which sets the default landing page for all users.




CMS_newlink.jpg