SPEntryPage: redirect to Service Portal by user role

stryker129
Mega Guru

Hi,

Here is a SPEntryPage Script Include snippet:

if (user.hasRoles() && user.getFullName() != "System Administrator" && user.hasRole('x_11111_notes.service portal')){

              //      

} else if (user.hasRoles() && !redirectURL && !isServicePortalURL)

    return;

and I would like to redirect users with role "x_11111_notes.service portal" to Service Portal homepage.

Looks like 1st IF condition doesn't work 'cause I created user with admin roles in system table Users - it also redirects to Service Portal Page. It's just because of newly create admin user is also has 'x_11111_notes.service portal'.

Can anyone advice where I am wrong? Is there any workaround?

Thanks.

1 ACCEPTED SOLUTION

Jon Barnes
Kilo Sage

an admin user will always return true for gs.hasRole(...) no matter what role you pass in there. So for your first if condition to work and to exclude admins, you need something like this:



  1. if (gs.hasRoles() && !gs.hasRole('admin') && gs.hasRole('x_11111_notes.service portal')) {  


I put gs here instead of "user" but I don't know what you have set user variable to, so that may be fine.


View solution in original post

7 REPLIES 7

I have 4 service portals and 4 users group and want to redirect them as per their group name or role. Please advise

Hey Jon, 

Suppose I want to redirect some user who has only one perticular role to service portal, but if they have additional role along with that then they will be able to see classic view. What I need to do

singhome
Kilo Explorer

Will this be applicable if i have to redirect users to different portals based on groups membership or roles?? Please comment