Redirect users based on roles

Divya57
Tera Expert

Hello everyone,

I have a requirement based on roles, users should redirect.

If suppose a user as 'snc_internal' role then after login user should redirect to 'sp' portal. If suppose a user as 'snc_internal' role and anyother role like 'itil' then user redirect to 'spsc' portal. whenever am querying the users with role 'snc_internal' if that user as 'snc_internal' and any other role am getting those users as well. I have gone through multiple articles in community but i didn't find any solution.

Below is the code am using:

var gr = new GlideRecord('sys_user');
gr.addQuery('user_name',gs.getUserName());
gr.addQuery('roles=snc_internal');
gr.query();
if(gr.next()){
this.portal = "/sp/";
}
else
this.portal = "/spsc/";

Here the problem is if the user is having 'snc_internal' and anyother role. he is also redirecting to 'sp' portal inside of 'spsc' portal.

Thanks in advance.

2 REPLIES 2

Jyoti8
Kilo Guru

Hi Divya,

Refer below Blog from ServiceNow, it might help you.

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

 

Please mark Helpful and Correct, if applicable.

Thanks..!

I gone through already this article. no help. I stuck in above code