Solved: Redirect users to portal if they have no role and/... - ServiceNow Community

Redirect users to portal if they have no role and/or a specific role

LikeARabbit
Giga Expert

Up until a month or so ago the majority of our end users had no roles assigned to them. Their only interactions with ServiceNow were forced through the Service Portal. However, when we deployed the Emergency Self Report application we were forced to grant everyone the sn_imt_quarantine.crisis_task_user role in order for them to access the application through the Service Portal.

Now that they have a role they are no longer classified as ESS users, which means they can now access the base platform. This is leading to confusion within our organization so we want to return to the original behavior of non-ITIL users being redirected to the Service Portal.

I've followed the steps outlined in this article - https://pathwayscg.com/service-portal-auto-redirect/ - but the issue persists. I've tried in both our DEV instance and my personal developer instance, same behavior in both.

Am I missing something with this article? How have others blocked platform access (redirecting to SP) for people without certain roles?

1 ACCEPTED SOLUTION
6 REPLIES 6

sachin_namjoshi
Kilo Patron
Kilo Patron

Check below for service portal redirection based on role

 

https://community.servicenow.com/community?id=community_blog&sys_id=cbcda2e9dbd0dbc01dcaf3231f961949

 

Regards,

Sachin

Thank you @sachin.namjoshi !

 

Turns out I had a typo, I was using 'user.hasroles("itil"). Instead it should be 'user.hasRole("itil"), singular vs plural. So line 69 in our SPEntryPage script include looks like this:

if (user.hasRole("itil") && !redirectURL && !isServicePortalURL)

Hi @LikeARabbit  Did the solution work out for you?

I am also trying the similar requirement.

itil user should navigate to home page and nd users with no roles should be routed to /sp page

But the changes didnt work for me

if (user.hasRole("itil") && !redirectURL && !isServicePortalURL)
return;

Please help me understanding if I am missing anywhere

Thanks @LikeARabbit  for posting the resolution, took me half a day to debug that extra s in baseline code.....