How to redirect from one ServiceNow instance to another?

akbalFTV
Tera Contributor

Hi, I have a requirement is to redirect a group of users from abc.service-now.com to xyz.service-now.com when they try to login to the "abc" instance. 

 

Currently, xyz is a clone of abc ServiceNow instance and all users are able to SSO into both abc and xyz instance. Both abc and xyz instance have SSO configured from the same Azure tenant. I've looked into Installation exits and SPEntry page script but not sure what's the right approach to take here.

 

Any suggestion on this is greatly appreciated. 

4 REPLIES 4

Shivalika
Mega Sage

Hello @akbalFTV 

 

Did you already created Installation exit ? It will help you redirect user while login and logout both and validation things. 

 

SPEntry Page is different, it works only for portal users. 

 

Create a new installation exit and try below 👇 script - 

 

(function executeRedirect() {

    var user = gs.getUser();

    var userGroups = user.getMyGroups();

    

    // Define the group that should be redirected

    var redirectGroup = 'xyz_redirect_group'; // Change this to your actual group name

 

    // Check if the user is in the redirect group

    if (userGroups.indexOf(redirectGroup) !== -1) {

        gs.getSession().setRedirect('https://xyz.service-now.com');

 

  }

})();

 

Let me know in case of any queries. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

 

Shivalika
Mega Sage

Hello @akbalFTV 

 

Thanks for marking my answer as helpful. 

 

Kindly accept solution if it helped you in anyway. This will help me be recognized for my efforts and also it can move from unsolved bucket to solved bucket. 

 

Regards, 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeE

Hi, I have tried this and it's not working. We have Multi-SSO installed in our system to authenticate with Azure, so I have overridden "MultiSSOLogin" installation script and included the necessary code form here. But it does not seem to be working.

@akbalFTV 

 

Why are you overriding it ? A new installation exit can't be created ? Did you try it ? 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY