How to Redirect Admins to a UI Page During Login for Validation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 05:26 AM
Hi all,
We want to implement a custom login flow in our ServiceNow instance that introduces an additional validation step only for users with the admin role. The goal is to ensure that administrators provide a valid reason and reference a specific record before they are granted access to the platform.
Detailed Requirement:
When a user attempts to log in using the standard login.do in ServiceNow:
Check User Role:
If the user does not have the admin role and tries to log in using login.do → Don't allow the user to log in instead, re-direct to the default login page(SSO).
If the user has the admin role and tries to log in using login.do → intercept the login and redirect the user to a custom UI Page.
Custom UI Page Behavior:
The UI Page should prompt the admin user to:
Enter a valid record number (of type INC, CHG, or RITM).
Provide a reason for login.
On form submission, the backend should:
Validate the provided record number by checking its existence in the corresponding table (incident, change_request, or sc_req_item).
Ensure the login reason is not empty.
Decision Logic:
If the record number is valid and a reason is provided → allow the user to continue to the home page (home.do) or record page(INC page).
If the record number is invalid or the reason is missing/empty → immediately log the user out (logout.do).
Audit (store the login information like record number and reason):
Store the admin’s login reason and the referenced record number for auditing purposes.
- What is working.
- Once the user enters their credentials and clicks on login, it redirects the user to the custom UI page by checking the role.
- On the UI page user can enter the record number, and the reason is entered. Even though the record is valid, we are unable to re-direct to the home page. It stays on the same(Custom UI page) with the values cleared.
- When I change the URL, the session is already logged in. It is supposed to redirect us to the home page automatically.
Login Page
Custom UI page
Here is the Script I have used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 05:33 AM
this seems to be an extra burden when it comes to maintenance.
so what debugging did you perform?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader