Admin and SOW Login Pages Not Working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2024 02:53 PM - edited ‎06-14-2024 02:53 PM
Good Afternoon,
I am having an issue when logging in as admin or any user with an 'itil' role. Users with admin role should reach the Admin Home page upon login and users with itil role should reach the Service Operations Workspace landing page.
I can get to these manually. However, upon login or clicking the logo in the top left it is almost as if the system is attempting to redirect to a dashboard on our test instance with the link below.
login:
logo:
https://xxxxxxx.service-now.com/now/nav/ui/classic/params/target/home.do
These should both redirect to either admin home or the SOW page depending on if an admin user or itil user.
I am very new to ServiceNow and this happened after I moved over a custom table I created. However, this issue did not occur in my test instance. I am not sure what was changed. Some things I have tried are checking the system properties and verifying that glide.login.home was set to /now/nav/ui/home. I also tried changing this to /now/sow/home as I was okay with setting admin home as user preference for myself and the other admin. This did not make a difference and users with 'itil' role still are not being redirected to the SOW landing page.
I also attempted to create a new entry on the Landing Page ( sys_ux_custom_content_root_elem ) table that states if your role is 'itil' redirect to the Service Operations Workspace. This also did not work and users are still getting the odd dashboard link.
Any assistance is much appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2024 03:14 PM
Hello @tiguin2798 ,
Hope you are doing well!
This might help 🙂
Use Case: If a user has a specific role ('itil') using a GlideAjax call to a ServiceNow Script Include ('UserRoleCheck'). If the user has the role, they are redirected to the '/csm' page and an alert is displayed confirming the role. This check is only performed if the current URL does not already contain 'csm'.
> Configure a global UI Script
> Applicable for Desktop
function checkUserRole(role) {
// Create a GlideAjax object and specify the Script Include name
var ga = new GlideAjax('UserRoleCheck');
ga.addParam('sysparm_name', 'userHasRole'); // Specify the method name in the Script Include
ga.addParam('role', role); // Add the role parameter to send to the Script Include
ga.getXMLAnswer(function(response) {
// Parse the response if needed
var hasRole = JSON.parse(response);
if (response === 'true') {
window.location.href = '/csm';
alert('User has the role: ' + role);
}
});
}
alert("--->"+ document.URL.indexOf('csm'));
// Example usage
if (document.URL.indexOf('csm') == -1) {
checkUserRole('itil');
}
> Configure a Script Include:
var UserRoleCheck = Class.create();
UserRoleCheck.prototype = Object.extendsObject(AbstractAjaxProcessor, {
userHasRole: function() {
var role = this.getParameter('role'); // Get the role from the client-side request
var user = gs.getUser();
var hasRole = user.hasRole(role);
gs.log('P1:CSM - User: '+gs.getUser().getName()+' || Checking role: ' + role +' || Has Role: '+hasRole);
if(user.hasRole('admin')){
return 'false';
}
return JSON.stringify(hasRole);
},
type: 'UserRoleCheck'
});
If the article helped you in any way, please hit the like button/mark it helpful. So it will help others to get the correct solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2024 05:52 PM
I am doing well, I hope you are! Thank you very much for your response.
I have created a global UI Script with the provided code as well as a Script Includes. I did get the message " --1" when logging in as admin, and the URL looks correct, but then it states my test environment failed to connect instead of pulling up the admin home page?
Unfortunately, logging in as users with only 'itil' role still produces the same issue. Is there anything in these scripts I should change? Not sure if client callable needs to be enabled for the Script Includes.