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

Can you provide the script you are using?


Sorry to seen this to late. There would be a couple of solution to fix this with a mixture of portal, spentrypage and system properties. But you will avoid ui scripts running on your system.


Hello Goran,

 

May you please specify what is the solution with the UI Script. It will be appreciated if you can give us the client side code for this UI Script and how to trriger it. I think that will help many of us who still struggling with this.

 

Best wishes,

Shay