Restrict a user with test_role from browsing /now/nav/ui/home.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 07:37 AM - edited 03-08-2024 12:35 AM
I have this complicated requirement. I need to restrict a user with a certain role, test_role from browsing using /now/nav/ui/home. What I mean is, I have a PDI https://dev201638.service-now/, I want to restrict this user from going to the browser and directly accessing /now/nav/ui/home by making this as url, https://dev201638.service-now/nav/ui/home at the browser. When this user does it, he needs to be redirected to the /esc page instead.
I tried using UI Script with this code below
addLoadEvent(function() {
console.log('THIS CODE RUNS');
if(g_user.hasRole('test_role') && document.URL.indexOf('/now/nav/ui/home') != -1) {
window.location='/esc';
}
else {return}
});
This code does not work because when we directly access /now/nav/ui/home, the page loads, and the UI Script is ignored. As you can see in the code, I added a console.log() which runs when you click any link(s) within the PDI, like accessing the Incident table, or refreshing the current UI Script in the browser.
Is this requirement solvable? Please help me, thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 08:03 AM
I alsa have same requirement