Mark Roethof
Tera Patron
Tera Patron

Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Hi there,

 

Out-of-the-box ServiceNow comes with several Service Portals. What if you want to deactivate some of these portals, and perhaps even redirect users? Since you might not support all of them, not need all of them, don't want users accidentally visiting some of these portals, etcetera.

 

Up to the Washington DC release this was not possible, or only with some very creative workarounds. With the Xanadu release... out-of-the-box it's been made possible to deactivate a portal and optionally redirect to another portal!

 

Let's have a closer look!

 

Pre-Xanadu

deactivate_portal_01.png

 

A fresh ServiceNow instance comes with these nine out-of-the-box Service Portals. Some serve their own purpose, some have a similar purpose. You might even see a few more on your instance, like Instance Security Center which was out-of-the-box (deprecated), or other ones that come with plugin installations.

 

If you wanted to deactivate or portal, just no-go. There's no active field available, and deleting a whole out-of-the-box portal feels a bit too much. Only through some workarounds you could prevent users from using a Service Portal directly. For example by changing the login page and the homepage to a 404 page, and removing the Header and Footer from the Theme.

 

Or what if you would like to redirect users from SP to EC, since EC is the new standard, not possible out-of-the-box. Through some smart workarounds you could force a redirect, like I shared in an article three years ago: Redirect (inactivate) Service Portal, e.g. from /sp to /esc. Basically the article describes how to implement a redirect by adding JS Include and UI Script which are linked to the Theme of the Service Portal concerned.

 

Xanadu

Browsing the Xanadu RTP release, eureka! Deactivating a portal and optionally redirecting it to an alternate portal.

 

deactivate_portal_02.png

 

Basically, an "Inactivate" and "Alternate portal" field were added to the Service Portal table and its Form Layout. 

 

deactivate_portal_03.png

 

Why ServiceNow decided to name it "Inactive" and not "Active", I have no clue. I can only mention that out-of-the-box there are 827 Active fields, and 4 inactive fields.

 

ServiceNow did a decent job documenting this new functionality when the Xanadu release notes became available. You can find the release note on this Docs page. There are a few things I want to highlight:

- You can't deactivate the default, you have to make a different Service Portal the default one first;

- You can't deactivate a Service Portal that is configured as an alternate portal by any other Service Portal;

- You can't deactivate or redirect to the Mobile Employee Service Portal (/mesp).

 

Although not bulletproof, ServiceNow did added a UI Policy (Hide Alternate portal if portal is active) and two Client Scripts (Hide fields & alerts when deactivating t, Portal Deactivation Validations) that should hide the inactive and alternate portal field and perform deactivation validations.

 

Inactive and Alternate portal fields not visible

Since this functionality is new out-of-the-box with the Xanadu release, why is this not instantly visible at every customer? Customization!

 

Like with many other new features visible on a Form Layout, if a customer in the past customized the Form Layout, then new out-of-the-box modifications won't automatically appear on the Form Layout. Instead while upgrading a Skipped Record will be created. Unfortunately handling Skipped Records is not something every customer does or understands. And... with the Xanadu release ServiceNow added Skipped Record Rules that amongst others would automatically ignore Form Layouts 😡. Why ServiceNow did this last bit, I have no clue. 

 

If the Inactive and Alternate portal fields have not been added to your Form Layout, do so yourself.

 

deactivate_portal_04.png

 

Result

When a Service Portal is deactivated and anyone tries to open that Service Portal, from now on a clear message is shown. When an alternate portal is set, automatically - and without delay - a redirect in the browser is performed. 

 

deactivate_portal_05.png

---

That's it. Hope you like it. If any questions or remarks, let me know!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

Independent ServiceNow Consultant
9x ServiceNow MVP

---

LinkedIn

Comments
dwtaber
Tera Expert

Is it possible to disable the "You're being redirected to..." alert that appears when a user is redirected away from an inactive portal?

Marko5
Tera Contributor

I am also interested in deactivating the message, which is displayed when you are redirected. The documentation is only mentioning the messages table, but not which record.

Here is the key for the message:

"you're being redirected to {0} as the portal you attempted to access has been deactivated"

 

I assume the redirect is done in the script include "SPEntryPage", but in that script the URLs are generated with the "GlideSPScriptable" class, which is not accessible for customers.

xamiloui
Tera Guru

Has anyone figured out how to disable the "you're being redirected to {0} as the portal you attempted to access has been deactivated" message?

Kev9
Kilo Sage

We're current still on WDC. We're about to move from /sp to /esc

If we have direct links to KB articles on the company website for example, how will these behave with a redirect in place?

Siddhesh Gawade
Mega Sage
Mega Sage

I am trying to find ""you're being redirected to {0} as the portal you attempted to access has been deactivated" in message but not able locate yet. Is anyone facing same issue? As per the documentation it should be available in message table.

Marko5
Tera Contributor

@Siddhesh Gawade 

I assume that the records will be created with activating the I18n Plugin and installing some languages. I have "messages" records for the languages which are configured at the instance and taking the fact that they have an empty "created" and "updated" field I believe it is coming from ServiceNow.

If you want to have alternative text messages you have to create your own "messages" record. WIth the same key you already have.

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @Marko5 ,

 

I deactivated service portal and selected employee center as a alternative portal. So when trying access SP it is redirecting me to ESC which is as expected. and I am seeing "You're being redirected to Employee Center as the portal you attempted to access has been deactivated" this message. So I am assuming this message should be already present in message table but I am not able find relevant message record. I don't think I need to install any plugins as I am already seeing the message in portal. let me know what you think.

Marko5
Tera Contributor

@Siddhesh Gawade 

You can execute e.g. "gs.getMessage('keyword')" without having a record with that "keyword" at the messages table. In my example it will just write "keyword".

 

That means you have to create your own message record with the key: "you're being redirected to {0} as the portal you attempted to access has been deactivated" and the value: "Welcome at the all new {0} portal" and servicenow will select your new messages record to display it at the service portal.

User517509
Tera Expert

Hello - Can someone please tell me how and where I would customize the message that redirects users from the SP to ESC? Do I need to create a brand new message or is there somewhere I can change the default message? Thank you! 

User517509
Tera Expert

Nevermind, Marko5 your suggestion above worked perfectly! 

bkeszl2
Tera Explorer

Hey Folks,

 

for anyone looking to remove the UI message on redirect, while currently SN is not allowing us to prevent adding the message, we are removing it by attaching a JS Include to the theme of the target portal, along the lines of: 

// Configure what DOM changes to watch out for
var notificationNode = document.getElementById("uiNotificationContainer");
var config = { attributes: false, childList: true, subtree: false };
var callback = function (mutationList, observer) {
    for (var mutation of mutationList) {
        // New notifiaction is added
        if (mutation.type === "childList") {	
            for (node of mutation.addedNodes) {
                // For each node, if it contains the specified UI message and is a Noticiation
                if (node.innerHTML && node.innerHTML.indexOf("insert UI message here") != -1 && node.className.indexOf("alert") != -1) {
                    node.childNodes.forEach(function(element) {
                        // Find the dismiss button
                        if (element.classList && element.classList.contains("dismiss-notifications")) {
                            // Click the dismiss button
                            element.click()
                            // Remove the notification from the dom so the animation doesn't play
                            node.remove();
                            // Disconnect the MutationObserver once we remove the message
                            observer.disconnect();
                        }
                    });
                }
            }
        }
    }
};

//Watch out for changes in the Notification center
var observer = new MutationObserver(callback);
observer.observe(notificationNode, config);

 

User517509
Tera Expert

@bkeszl2 
Hello - I am trying to do exactly what you have described. Can you provide additional guidance around "attaching a JS Include to the theme of the target portal" 

 

Thank you!

bkeszl2
Tera Explorer

Sure @User517509,

Open the "sp_portal" record that you are redirecting to, scroll down to the related lists section and select the "JS Includes" one. Add a new one, it will also let you to create a UI script. Create the UI script too, and paste the code from my above comment in there. Make your modifications, especially to the section where I wrote: insert UI message here

 

Then save, and the message should be gone on subsequent portal loads.

Good luck! 

Berin
Tera Guru

Thankyou @bkeszl2!!! That was extremely helpful! If anyone else is having an issue with the code loading before the notificationNode renders, we resolved this by wrapping the code in a DOMContentLoaded event listener. Eg:

document.addEventListener("DOMContentLoaded", function(){
    // bkeszl2's code...
});

 

Version history
Last update:
‎08-04-2024 10:35 PM
Updated by:
Contributors