Redirect URL

Brian Lancaster
Tera Sage

We want have service now request page redirect the user to another page but I would also then like to have service now redirect to the home page.   I have created a on load script that opens a new page but I cannot figure out who to get service now to go back to the home page.   Here is the script I have.

 

function onLoad() {

  window.open("http://www.w3schools.com");

  action.setRedirectURL('home.do');

}

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

Since you're in a client script (not a UI action) you'll need to use something like this...



window.location = 'home.do';


View solution in original post

4 REPLIES 4

Mark Stanger
Giga Sage

Since you're in a client script (not a UI action) you'll need to use something like this...



window.location = 'home.do';


thank you for this, very helpful!


Bhavesh Jain1
Giga Guru

RedirectURL can be used only in Business rule.


For client script, you will need to write window.open again to redirect.


Also you can make use of document.referrer if you want to know the previous URL.




Regards,


Bhavesh


IGate-logo.png


http://www.igate.com


nehakakkar
Tera Contributor

Use this script to solve it.


@Brian Lancaster wrote:

We want have service now request page redirect the user to another page but I would also then like to have service now redirect to the home page.   I have created a on load script that opens a new page but I cannot figure out who to get service now to go back to the home page.   Here is the script I have.

 

function onLoad() {

  window.open("http://www.w3schools.com");

  action.setRedirectURL('home.do');

}

 


The script you provided will open a new page with the URL "http://www.w3schools.com" using window.open(). After that, it sets the redirect URL for the current ServiceNow page to 'home.do' using action.setRedirectURL().

The ServiceNow is redirected back to the home page, make sure that the 'home.do' URL is the correct URL for your ServiceNow instance's home page. Adjust the URL as needed.