mr18
Tera Guru
Tera Guru

This article is basically to configure domain separation for Service Portal.

Till date ServiceNow hasn't provided solution for Domain Separation for Service Portal. 
Which mean: Your instance is domain separated and you have two or more than 2 domains, each having separate Service Portal.
User from X domain has Service Portal (URL suffix: xyz) and users from A domain has different Service Portal (URL suffix: abc).
So if somehow user from X domain knows the Service Portal URL suffix for A domain then he will be able to create incident/request, view knowledge articles of A domain which is a security breach.

This article will help you to restrict users to their domain Service portal only. Even if user tries to access the other domain portal, he will redirected to his domain Service Portal

All you need to do is:

1. Create a Script Include to check if the user is from particular domain

Name: getMyPortal
Client Callable: true

var getMyPortal = Class.create();
getMyPortal.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    xPortal: function() {
        var dom = gs.getUser().getDomainID();
        if (dom == '<sysID of the domain X') 
		{
            return true;}
            
         else
            return false;
    }
});

 

2. Create UI Script

UI type: Mobile/Service Portal

(function() {

    var ga = new GlideAjax('getMyPortal');
    ga.addParam('sysparm_name', 'xPortal');
    ga.getXML(NewParse);

    function NewParse(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if (answer == 'true') {

            window.location = '/xyz';
        }
    }
})();
portals;

 

3. Create new JS include in the theme related list of Portal A and add the UI script there

 

Note: This solution is for one domain redirection. that means if user from X domain tries to access abc portal, he will be redirected to xyz portal.
In order to the redirection for abc portal also, you have to create another Script include to return the abc domain and then create another UI script which you will add to xyz portal theme.

Comments
Christopher Maq
Tera Explorer

Hi, 

Im am trying to do the same thing. Has this solution worked for you? 

mr18
Tera Guru
Tera Guru

Hi Christopher,

Yes, the solution worked for me.

Please follow the same steps as mentioned above.

vivian08081
Giga Expert

Hi  @mr18 

 

Cloud you please give some detail for the step3?

mr18
Tera Guru
Tera Guru

Hi @vivian08081 

For step3, open the theme of other service portals and go to the JS include related list and create new

mr18_0-1667050310722.png

 

mr18_1-1667050371729.png

 

Select the UI Script created in step2

mr18_2-1667050459348.png

 

Let me know if still you have any doubt

 

IrfanAhmadW
Tera Contributor

Hi @mr18,

Can you please elaborate what I need to do for such implementation.

 

Version history
Last update:
‎12-02-2020 10:01 PM
Updated by: