Set Dashboards on User Landing Page based on roles

Ashwin Perumal1
Tera Contributor

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.

2 ACCEPTED SOLUTIONS

Iraj Shaikh
Mega Sage
Mega Sage

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.

IrajShaikh_0-1704633356060.png
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.

IrajShaikh_1-1704633937177.png

 

Please mark this response as correct or helpful if it assisted you with your question.



 

View solution in original post

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.

View solution in original post

9 REPLIES 9

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.

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.

Hi Ashwin,

 

Disable auto-redirection for all agents to Service Operations Workspace

     Role required: admin

     Procedure:

  1. Change application scope to Service Operations Workspace Core
  2. From the All menu, navigate to sys_homepage_destination_rule.list.
  3. 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...)
  4. Clear the Active check box.
  5. Select Update.
    IrajShaikh_0-1704699640140.png

     

Please mark this response as correct or helpful if it assisted you with your question.

 
 
 
 

 

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.

Hi Shaikh,
It works perfectly now. Thanks for the support. Now based on roles my dashboard at landing page differs. Thanks Shaikh