UI script to work automatically without being called
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2025 07:36 AM
Hi,
I have written a UI script to check logged in users' role and if user has a specific role only, then he would be redirected to the Portal page.
(function() {
if (window.self === window.top) {
if (g_user.hasRoleExactly('user')) {
var currentURL = window.location.href;
if (currentURL.includes('.do') && !currentURL.includes('/sp') && !currentURL.includes('/nav_to')) {
window.location.href = '/esc';
}
}
}
Currently When I set the UI type to ALL, the global checkbox is disabled. So I can't run it automatically on all the pages that user tries to enter in the URL. Is there any way to do this? I am looking to restrict the user to the portal only when user tries to provide a deep link in the URL.
Any help is appreciated. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Not sure if hasRoleExactly() works in server side script, but I tried with role validation in the script include but deep links bypass it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi @Kevin Paul
What is relation between ui script and portal. did you added the ui script to your portal theme?
if yes how ?
Regards,
Krishnamohan