Assistance Required with Portal Routing Logic Based on User Company
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2024 05:47 AM
Hi Expert
I have a requirement related to portal routing that I need some help with. Here's the scenario:
- If a user belongs to company "ABC," they should be routed to the Service Portal (SP).
- If a user belongs to company "XYZ," they should be routed to the Customer Service Management portal (CSM).
- After logging out, the user should be redirected to the common login page (SP landing page).
I’ve created a new Script Include that inherits the SPEntryPage Script Include. In the initialize function, I added the following code:
When I impersonate a user from company "XYZ," the CSM portal is displayed as expected. However, when I log in using my credentials (from company "XYZ"), it always redirects me to the Service Portal (SP) instead of the CSM portal.
Could you please assist me in resolving this? I suspect there may be an issue with how the user's company is being checked or how the logic is being applied during login.
Looking forward to your guidance on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2024 07:40 AM
when you impersonated with user from XYZ what came in log?
when you impersonated with user from another company what came in log?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2024 08:40 AM
I have added following logs,
When i tried with credentials following code triggered thrice. 2 times for csm user and 1 times for guest user.
But when i impersonate, same code trigger twice. and both times for CSM user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2024 05:58 AM
Hi @Gulfam ,
Your code looks okay, you need to check routing. try printing the log to troubleshoot.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2024 06:53 AM
Hi Runjay,
I have write the logs, it's showing csm portal in logs, When i impersonate with XYZ user then it takes me to the CSM portal and when i try to log in using XYZ user then it take me to the SP portal.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2024 06:48 AM
Your encoded query could be troublesome with doing a contains search. You're also limiting the search to only users with a class of contact.
Are you only wanting this to apply to a single company record? Or are there actually many companies this needs to work for.