How do i make a ui page to redirect to other pages based on conditions

Ryan Norton
Giga Contributor

Basicly what im trying to do is change the logon page so that users within a specific known ip range go to our sso page and other users go to the side door logon page.

1 ACCEPTED SOLUTION

I will preface my statement with the comment that we do not use public pages - we keep all our content secured.



My understanding is that you can use a public Page from a Content Site. This public Page will contain a dynamic content block, and that dynamic content block can contain Javascript (and other languages). Because you have the ability to use Javascript within your dynamic content block you can go ahead and do whatever you want to do.



For example, I created this public page (at least I sure hope I did) on a demo instance:


ServiceNow



When you go into the code you will see the simple content of my dynamic block:


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


Test public page


  <script>


  alert("Test");


  </script>


  <g:evaluate>


  var test123 = "test123";


  test123 = gs.getSession().getClientIP().toString();


  </g:evaluate>


  <br/><br/>Your IP is: ${test123}


</j:jelly>



So when you navigate to the public page it loads some text ("Test public page"), has a popup, then displays your IP. You can put whatever Javascript or Jelly you want in there - I have just provided two basic examples.



Hopefully that helps you get started? It shows you how to create a public page (Making a Page Public - ServiceNow Wiki , how to create a dynamic block to utilize Jelly and Javascript, and how to display the IP. You can then just code in the logic you want based on the IP.




I know ServiceNow had Login Rules in the past and such, it might be worth exploring whether they have something built in to do this. We have no need, so I never explored it.



As well, I see you are in Edmonton as well - you can always talk to Jamie (one of your local SN tech guys) and have him help you out too!


View solution in original post

5 REPLIES 5

TrevorK
Kilo Sage

This may be a silly comment - but wouldn't you be better off looking into delivering this via a public Page (with a dynamic content block) from the CMS system?



I am not sure how far you have gone with this, so obviously if you're already building a solution focused around a UI Page then feel free to ignore this. I just know we do some user redirection within the CMS and found that to be the best solution.


i have no idea where to start, A public page was what i had in mind, but i'm not sure how to script page redirection or getting an ip address prior to a user logging in into a content block. i have found "gs.getSession().getClientIP().toString();" to get an ip address and "action.setRedirect("page link goes here");" to redirect the page... that's about as far as i've gotten.



I will preface my statement with the comment that we do not use public pages - we keep all our content secured.



My understanding is that you can use a public Page from a Content Site. This public Page will contain a dynamic content block, and that dynamic content block can contain Javascript (and other languages). Because you have the ability to use Javascript within your dynamic content block you can go ahead and do whatever you want to do.



For example, I created this public page (at least I sure hope I did) on a demo instance:


ServiceNow



When you go into the code you will see the simple content of my dynamic block:


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


Test public page


  <script>


  alert("Test");


  </script>


  <g:evaluate>


  var test123 = "test123";


  test123 = gs.getSession().getClientIP().toString();


  </g:evaluate>


  <br/><br/>Your IP is: ${test123}


</j:jelly>



So when you navigate to the public page it loads some text ("Test public page"), has a popup, then displays your IP. You can put whatever Javascript or Jelly you want in there - I have just provided two basic examples.



Hopefully that helps you get started? It shows you how to create a public page (Making a Page Public - ServiceNow Wiki , how to create a dynamic block to utilize Jelly and Javascript, and how to display the IP. You can then just code in the logic you want based on the IP.




I know ServiceNow had Login Rules in the past and such, it might be worth exploring whether they have something built in to do this. We have no need, so I never explored it.



As well, I see you are in Edmonton as well - you can always talk to Jamie (one of your local SN tech guys) and have him help you out too!


This is exactly what i need. would you by chance be able to attach an update set containing this page? I'm not able to see what you used to get the ip address...