Service Portal - Redirect via UI Script

Blair5
Tera Guru

This is part of a UI Script that redirects a user based on roles. Line 21 isn't being called because window.localStorage isn't coming back as null (this seems to only happen if the user has a specific role).

I logged the window.localStorage in another instance that is still using CMS (and an older version of this UI Script) and it came back as null. Any ideas???

addLoadEvent(function() {

try{

if ( typeof g_user.userName != "undefined" && g_user.userName == 'guest' ) {

window.localStorage.removeItem('evgRedirectLaunched');

console.log('[RedirectHandler] Removed evgRedirectLaunched key, on login page');

}

if ( typeof g_user != "undefined") {

if ( typeof g_user.allRoles != "undefined") {

if ( g_user.allRoles.indexOf('ess_it_user') == -1 && g_user.allRoles.indexOf('admin') == -1 ) {

window.localStorage.removeItem('evgRedirectLaunched');

console.log('[RedirectHandler] Removed evgRedirectLaunched key, user is ESS user');

}

}

}

var evgDirectLaunched = window.localStorage.getItem('evgRedirectLaunched');

console.log('evglaunch: '+evgDirectLaunched);

if ( evgDirectLaunched == null ) {

console.log('[RedirectHandler] evgRedirectLaunched NOT set, processing launchredirect, g_user.userName = '+g_user.userName);

launchredirect();

}

} catch (err) {

console.log('[RedirectHandler] Error: ' + err);

}

});

12 REPLIES 12

This a UI script which is client based, so that won't work.


Blair5
Tera Guru

I really need help with this. I've exhausted my avenues and ended up getting locked out of my instance twice. Any help or best practices are very much appreciated. If you could give examples as well, that would be awesome!


Blair5
Tera Guru

Another bump -- I see tons of posts regarding this, but nothing give a full solution that will help me. Will the SPEntry script include work for us even though we have 3 portals? If so, how? I found a youtube video describing how we can add a portal reference to the company table and route based on the user's company. How can I do that by role instead? Will users without a certain role be forced to stay on the portal? Will the SPEntry script include allow for certain users to navigate to the IT view if necessary? So many questions!



We are on Helsinki Patch 11 FYI


Hi Blair,



Have you found a solution for this.



Best regards,


Hi Rody,



We ended up reusing a global UI script we had in place and changed the CMS site to the portal site based on the user's role.