- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-07-2024 03:09 AM
Hello All,
I have a requirement to display dashboards on users landing page(home page) based on roles. If the logged in user has admin role then when user logs in every time then XXX dashboard should be visible by default as landing page similarly if user with itil role logs in then for that user YYY dashboard should be visible in landing page (homepage) by default. How could I achieve this is there any system property or user preferences. Can anyone help me on it Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-07-2024 05:27 AM
Hi @Ashwin Perumal1
1. Create a UI page:
- Navigate to System UI > UI Pages.
- Click "New" to create a new UI Page.
- Fill in the fields:
- Name: Enter a unique name for the UI Page (e.g., "RoleBasedRedirect").
- HTML: Enter the following HTML and JavaScript code:
- Please ensure that you replace 'sys_id_of_XXX_dashboard' and 'sys_id_of_YYY_dashboard' with the actual sys_ids of the dashboards you have created for the admin and ITIL roles, respectively.
<html>
<head>
<title>Redirecting...</title>
<script type="text/javascript">
addLoadEvent(function() {
var userRoles = '${gs.getUser().getRoles()}'.split(',');
var redirectUrl = '';
// Replace with the actual sys_id of the dashboards
var adminDashboardSysId = 'sys_id_of_XXX_dashboard';
var itilDashboardSysId = 'sys_id_of_YYY_dashboard';
if (userRoles.includes('admin')) {
redirectUrl = '/$pa_dashboard.do?sysparm_dashboard=' + adminDashboardSysId;
} else if (userRoles.includes('itil')) {
redirectUrl = '/$pa_dashboard.do?sysparm_dashboard=' + itilDashboardSysId;
} else {
// Default redirection for users without the admin or itil role
redirectUrl = 'home_splash.do?sysparm_direct=true';
}
// Perform the redirection
window.location.href = redirectUrl;
});
</script>
</head>
<body>
<p>Redirecting, please wait...</p>
</body>
</html>
While saving the UI page, you will see a pop-up window as shown below. You can select 'public' and click ok.
By assigning the "public" role, you ensure that all users who have logged in can be redirected appropriately based on their roles.
If you want to restrict access to the UI Page to only certain roles (which is not typical for a login redirection page), you can select those specific roles instead. However, in this case, since the UI Page is meant to be accessed by any user post-login, the "public" role is the appropriate choice.
2. Set the glide.login.home Property:
- Navigate to System Properties > All Properties.
- Search for the property glide.login.home.
- Set the value to the URL of the UI Page you created (e.g., ui_page.do?sys_id=your_ui_page_sys_id).
- Save the changes.
Replace the sys id with the sys id of the UI page that you have created above.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-08-2024 12:07 AM - edited ā01-08-2024 12:08 AM
Hi Ashwin,
In order to prevent itil users from redirecting to service operations workspace. Please follow steps from servicenow documentation here
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-07-2024 08:58 PM
Hello Shaikh,
Yes, I have changed the sys_id and tested below. I have created a new admin and ITIL user and when my admin user logs or Impersonate with my new admin user it redirects to the dashboard as per my UI page code , but when my new ITIL user logs in it redirects to only service opeartions workspace not to my dashboard. I am not understanding why. Can you please help me out on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-07-2024 10:39 PM
Hi Shaikh,
I have changed the sys_ I'd in both and tested the below scenario.I have created a new admin and itil user for testing.When the admin user logs in it redirects to the dashboard as per UI page code but when my itil user logs in it redirects him to service operations workspace as per OOB. I am not understanding why this is not working for ITIL user.Can you please help me on this to solve the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-07-2024 11:49 PM - edited ā01-07-2024 11:50 PM
Hi Ashwin,
Role required: admin
Procedure:
- Change application scope to Service Operations Workspace Core
- From the All menu, navigate to sys_homepage_destination_rule.list.
- Select the SOW Landing Page record.
(https://your-instance-name.service-now.com/nav_to.do?uri=sys_homepage_destination_rule.do?sys_id=6b5...) - Clear the Active check box.
- Select Update.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-08-2024 12:07 AM - edited ā01-08-2024 12:08 AM
Hi Ashwin,
In order to prevent itil users from redirecting to service operations workspace. Please follow steps from servicenow documentation here
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-08-2024 02:01 AM
Hi Shaikh,
It works perfectly now. Thanks for the support. Now based on roles my dashboard at landing page differs. Thanks Shaikh