UI Script for portal redirect based on role not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 12:46 PM
I have this UI script
(function() {
var isInternal = g_user.hasRole('snc_internal', true);
if(!isInternal) {
var loc = window.location;
//var oldUrl = loc.protocol + "//" + loc.host + loc.pathname + loc.search + loc.hash;
var newUrl = loc.protocol + "//" + loc.host + "/kc" + loc.search + loc.hash;
window.location.replace(newUrl);
}
})();
it's attached to a theme for my service portal. I would like to redirect users who land on that portal to the /kc portal.
(function() {
var loc = window.location;
//var oldUrl = loc.protocol + "//" + loc.host + loc.pathname + loc.search + loc.hash;
var newUrl = loc.protocol + "//" + loc.host + "/kc" + loc.search + loc.hash;
window.location.replace(newUrl);
})();
This version works with no issues. It's not until I add the conditional statement that I run into issues. Any idea on why that isn't working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 10:59 PM
Hi @Garrett2 ,
Can you please check below articles and threads. Might be helpful :-
6 ways to set up your Service Portal for redirection SUCCESS!
Issue while redirecting to service portal based on roles
UI Script for portal redirect based on role not working
Service Portal - Redirect via UI Script
Redirect users to different pages based on roles