Redirect to URL from Login Rule

ahaz86
Mega Guru

Hello,

I am trying to redirect to a specific URL in a login rule. I have tried doing gs.setRedirect(url) which does redirect but it seems to also throw a bunch of errors.

Does anyone have any suggestions? I am trying not to use a UI script on this...

Thanks,

Alex

2 REPLIES 2

Valor1
Giga Guru

Just a note, Login Rules are Deprecated.



Deprecation aside, I've not gotten Login Rules to work effectively.


You could customize the Installation Exit to redirect using gs.setRedirect(uri) -- we do this to resolve deep linking issues with CMS for our customers.



If you're looking at the "Login" Installation Exit, you'd insert your redirect command   before the statement "return user.getUser(userName)" on line ~15.


Thijs Daemen
Mega Guru

Hi Alexander,



I don't think you can actually script a redirect in the login rules. Login rules can set advanced conditions with scrips, but that is about it. They can either redirect to an specific content page (cms) or the default UI.



You might be able to find some info here: http://wiki.servicenow.com/index.php?title=Login_Scenarios#Logins_and_the_Employee_Self-Service_Port...



Otherwise, there is a nice update set with useful functionality by John Andersen at Add Role Based Home Pages with SAML 2.0 in ServiceNow-John Andersen. this solution modifies your SAML 2.0 login script by setting a relayState URL, you could also make this configuration without using the role based home page update set. In that case valor's advice on inserting a gs.setRedirect is another good option.



Last one on the wiki is Specifying a Login Landing Page - ServiceNow Wiki. This would be system wide, so for all users.