- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 08:13 AM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2017 06:58 PM
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:
- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2017 06:17 PM
Hi Ivan,
It mostly looks ok script wise.
Perhaps you could try splitting up that if check in to nested statements with log statements in between so you can see where it's matching/not matching.
Cheers,
Stephen

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2017 06:58 PM
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:
- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2017 05:51 AM
Hi Jonathan,
I have a requirement.
I want to redirect the enduser to SP depending on their respective domain.As the environment is Multi-tenant?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2017 09:49 PM
This will be very easy.
If domain separation is activated then include the SP table.
Please follow the below link to apply domain separation on the sp_portal table.
In Portal Page also you can define the domain so that it will appear for the specific user of a specific domain.
That will help you sure because I also had a similar requirement.