Service Portal Domain Separation workaround
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.
https://www.servicenow.com/community/itsm-articles/service-portal-domain-separation-workaround/ta-p/2307712