- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
‎12-23-2022 11:10 AM - edited ‎12-25-2022 10:58 AM
Background : Employee Center is the new portal solution that every new/old customer is looking forward to. Since EC has been introduced as a centralised portal catering to all you different departments (E.g. IT, HSE , Procurement etc.) through different topics within the same homepage. This excludes the need of having an individual portal for each department.
Use Case : As we migrate to a new portal (EC in this case) , we tend to update the URL suffix of the NEW EC portal to the OLD one. However, in case of multiple portals which are now being dealt through individual topics within EC , we can't do the same. In addition , there would be internal applications within your customer's infrastructure which will still contain the link to those OLD portals. It might take some time to update all those links. So, as a solution to this, we can implement a portal redirection so that the end users are being re-directed to the NEW URL even if they hit the OLD one.
Solution :
STEP 1 : As a first step ,we have to first create a widget as follows :
Server Script :
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var baseURL=options.base_url+''; //Base url would be retrived from option schema
var portalGr=$sp.getPortalRecord(); //Gives you GlideRecord object of the portal that you're navigating to
var portalName=portalGr.getDisplayValue('url_suffix'); //Retrieves the URL suffix of the portal
if(portalName=='<URL suffix of the Portal 1>'){
data.redirect_url=baseURL+gs.getProperty('<propert created with sys_id of the corresponding topic>');
}
else if(portalName=='<URL suffix of the Portal 2>'){
data.redirect_url=baseURL+gs.getProperty('<propert created with sys_id of the corresponding topic>');
}
})();
Client Script :
api.controller = function() {
/* widget controller */
var c = this;
top.window.location = c.data.redirect_url; //Code for re-direction
};
Option Schema :
STEP 2 : Once your widget is being created , open the homepage of the PORTAL (where you want the redirection to work) . From the related list, create a new container as shown below :
STEP 3 : Once done, attach your new widget through an instance within the newly created container. Boom ..!! every time you hit the portal url , it will redirect you the corresponding topic on EC.
Abbreviations used in the article :
1. EC used for Employee Center
Thanks & Regards,
Subham Kumar Shaw
Senior ServiceNow Consultant
ServiceNow Community Rising Star'2022
- 3,125 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very helpful
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very good explained. mine is done
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi,
This is very good, can I ask for two more options:
1) Option to display a message before the redirection. For ex: 'This portal is moved and new URL is....'
2) Option to add a wait timer (say 10 sec) before the actual redirection happens.
Please help me on how to add these two features to this widget.
Thank you
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
You can enclose the client script in the setTimeout() function , as shown in the below script :
setTimeout(function(){
alert("You would be redirected from portal xyz to abc");
top.window.location = c.data.redirect_url; //Code for re-direction
},5000)
Note : 5000 refers to 5 sec of pause before the re-direction occurs