Redirect to custom url when user used service-now.com URL.

Jan Post2
Tera Contributor

Hi,

 

We have a custom url active eg. https://acme.mydomain.com which redirects customers to the csm portal. So, when users go to https://acme.mydomain.com they end up with https://acme.mydomain.com/csm.

The old service-now.com url also stills works, and when used results in https://acme.service-now.com/csm. However, we want to redirect customers to https://acme.mydomain.com/csm when using https://acme.service-now.com. How and where to accomplish that?

 

Regards

Jan

4 REPLIES 4

Mark Manders
Tera Patron

Did you make the custom URL the instance URL? 

Yes.

Sumanth16
Mega Patron

Hi @Jan Post2 ,

 

The following script work for native UI. Create an UI Script with the following:

 

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 && document.URL.indexOf('login_locate_sso') == -1) {  

 

                  // Redirect to ServiceDesk

 

                  window.location = 'https://your-instance.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 ServiceDesk

 

                  window.location = 'https://your-instance.com/ess/';

 

}

 

});      

 

For portal:

If you want to do it same configuration on portal you should go to spentrypage script include.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0746730

 

Please test it by impersonating different users.

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda