
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
09-26-2021 09:57 PM - edited 08-03-2024 07:05 AM
Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
The method described in this article became obsolete with the introduction of "Deactivate a portal and optionally redirect to another portal" in the Xanadu release. |
Hi there,
Out-of-the-box, ServiceNow Instances are shipped with nine different Service Portals. Maybe you've added some additional plugins which increase this number or created a custom Service Portal. What if you would like to deactivate some of these Service Portals? As some are specifically targeted for end-users, while you are only using one or two of those Service Portals for end-users? For example because you have a /sp, /hr, /csm, and you are switching over to Employee Center (/esc).
Unfortunately, deactivating a Service Portal is not possible. There's not something like an active flag. So what can we do?
Delete?
As mentioned, deactivating a Service Portal is not possible. Theoretically you could delete a Service Portal. I haven't seen any best practices on this, though personally I wouldn't go for this option.
- What if for whatever reason you want to go back to that Service Portal or you need a specific part of that Service Portal?
- When it concerns an out-of-the-box Service Portal, changes might be done during Hot Fixes, Patches, or Upgrades. These will be added or will cause Skipped Updates.
Page Route Maps?
Deactivating a Service Portal is not possible, deleting a Service Portal is not a good go-to. What about redirecting, would that be possible? Out-of-the-box, there is the option "Page Route Maps". With this for example, you can redirect your HR ticket pages to the Standard Ticket page in Portal. This option is page-specific, so it does not redirect your Service Portal itself.
There's no other configuration that helps you redirecting within Service Portal. Redirecting when a user opens /sp or /sp?id=sc_home, having the user redirected to /esc for example.
JS Include!
Redirecting is possible though with a small workaround! You could add a JS Includes on a Theme record that is associated with the specific Service Portal you want to redirect. JS Includes will be loaded on attempt to display every URL. Within the JS Includes record, you can create a UI Script which makes redirection possible using the JavaScript object window.location.
Service Portals > Theme
Open the Theme associated with the Service Portal concerned.
Theme > JS Includes
Add a new JS Includes record on the Related List at the bottom of the Theme record.
JS Include > UI Script
Add a new UI Script record on the JS Include record.
UI Script
Set the UI Type to "All" and add the scripting concerned.
(function () {
window.location.assign("/esc");
})();
Result
When a user opens the /sp Service Portal, almost instantly the user is redirected to the Employee Center (/esc).
---
And 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? |
Kind regards,
Mark Roethof
ServiceNow Technical Platform Architect @ Quint Technology
2x ServiceNow Developer MVP
2x ServiceNow Community MVP
---
- 14,640 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Interesting approach!
What if the redirecting should be condition based? For example, only redirect users with the role "snc_external" (end users).
Kind regards
Maik

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Sounds like should be possible. Haven't tried yet. Was focussing now for a project on redirecting for example /sp > /esc and /sp?id=sc_cat_item&sys_id=249833602fccf010cd5dd99df699b664 > /esc?id=sc_cat_item&sys_id=249833602fccf010cd5dd99df699b664
Will share the second one asap.
Kind regards,
Mark

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
The answer is yes, is possible also. You can perform GlideAjax for example with which you should be able to achieve this. I will be sharing an example using this approach in the future.
Kind regards,
Mark
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Mark & Maik ,
I have the same question, how to redirect end users to /esc instead of /sp..? Any thoughts on this?
As you both aware, for redirecting end users to /sp : I have created a property "glide.entry.first.page.script" and used this "new SPEntryPage().getFirstPageURL()".
Regards,
Sriraj
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Mark
Can you elabarote more, I would like to try this for redirecting only end users to /esc instead of /sp.
Regards,
Sriraj

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
What do you need to elaborate more? Which part is unclear for you from the article?
Kind regards,
Mark
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Mark,
Regarding Maik's question about role based conditional redirect, you mentioned using GlideAjax, could you please eleborate more on that?
Thought the reason why GlideAjax, might be because cannot use gs.hasRole with UI script, so I checked if the employee has alumin role on the backend and send the result to the UI script. I have attached my UI Script along with the Script Includes. Currently, they are not working. Look forward to your reply, thanks!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi
Just to answer my own question: how to make role-based portal redirect, the tested and worked UI script & Ajax are posted here:
Use case: when Alumni logins, portal restricts user to Alumni Service Center
Use GlideAjax to determine the role of the current login user on the backend and send the decision to the frontend.
In Line 6, the logic will determine if the script triggers. If the employee already in the asc, they don’t need to be redirected.
Application scope should correspond to the one for the UI script (in this case Employee Center Core)
Line 5, gs.hasRole includes admin, so need to account for that (not sure if need to put !gs.hasRole(“admin”) on both sides of the OR statement, correct me if wrong).
Script Includes’ ACL requires the roles based on which portal redirects (not sure needed but just to be safe)
Please mark this helpful for encouragements 🙂
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This was helpful. I modified the UI Script a little to intercept any link with the /sp in it to redirect to the /esc portal. Seems to working.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Can this solution work if I want to redirect all users that are not admin from the /esc to the login.do page?