page redirection for custom URL based on user role

JahnaviC
Tera Contributor

I have a custom URL that directs to instance for all users. I have created a business rule to check the user role and direct them to Service portal if the user does not have ITIL role but it's not working. Is there a better way to redirect non-ITIL role user to the service portal and itil role user to the Instance.

 

(function executeRule(current, gForm, gScripting) {
var itilUser = gs.hasRole('itil'); 

if (itilUser) {
gs.getSession().setRedirect('/home.do'); 
} else {
gs.getSession().setRedirect('/sp?id=***')
}
})();

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@JahnaviC 

business rule is not recommended.

you will have to make changes to script include SPEntryPage and function getFirstPageURL and some system properties

check these links

6 ways to set up your Service Portal for redirection SUCCESS! 

How to configure redirection for Service Portal 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@JahnaviC 

business rule is not recommended.

you will have to make changes to script include SPEntryPage and function getFirstPageURL and some system properties

check these links

6 ways to set up your Service Portal for redirection SUCCESS! 

How to configure redirection for Service Portal 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@JahnaviC 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader