Landing page based on role

Vimal Priya
Giga Guru

Hi All,

Based on my requirement ,

I have created a new role "end_user" and it does not have have any "contained role " (which has end user access ) .

If the user has 'end_user' role , after logging it has to redirect to the ess page instead it redirects to navpage.do with enduser modules.

1.png

See attached img.

I have modified login rules

1.Users without Roles to ESS :

if(!gs.getUser().hasRoles()&&(gs.getUser().hasRole('end_user')))

gs.setRedirect("/ess");

2.Users with Roles to FrameSet

if(gs.getUser().hasRoles()&& (!gs.getUser().hasRole('end_user')))

  answer = true;

But NO RESULT.

Please help me on this .

1 ACCEPTED SOLUTION

Vimal Priya
Giga Guru

Hi All,



I resoleved by doing the below steps.



1.set false Direct navigation


2.users without roles


if(!gs.getUser().hasRole('admin')||(!gs.getUser().hasRole('itil')))


  answer = true;


(content page \ess)


3.users with roles


if(gs.getUser().hasRole('admin')||(gs.getUser().hasRole('itil')))


  answer = true;


default UI


View solution in original post

6 REPLIES 6

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Pradeep,



I have tried on UI scripts .



It's Working fine.



Can you please suggest which is best practice to use among the following?


1. UI Scripts.


2.Installation Exit



Since Login Rule does not works as expected .


Brad Tilton
ServiceNow Employee
ServiceNow Employee

I think your condition is wrong in the first one. If the user has a role, then !gs.getUser.hasRoles() will always be false.



!gs.getUser().hasRoles() || gs.getUser.hasRole('end_user');



Also, you do the redirect in the gui, so you should take that out of the script.


Hi Brad,



I tried using OR Condition in Login Rule but no use


1. Users without Roles to ESS



Active :false



/*if(gs.getUser().hasRole('end_Support')||(gs.getUser().hasRole('end_user')))


gs.setRedirect("/ess");*/



if(!gs.getUser().hasRole('admin')||(!gs.getUser().hasRole('itil')))


  answer = true;



2. Users with Roles to ESS




Active :false




if(gs.getUser().hasRole('admin')||(gs.getUser().hasRole('itil')))


  answer = true;



3. Direct Navigation



Active :true



var s = gs.getSession().getProperty('starting_page');


answer = !GlideStringUtil.nil(s);