action.setRedirectURL in Client Scripts.

Stewe Lundin
Mega Guru

I have UI Action button I want to trigger

var url='/myurl.do' ;

action.setRedirectURL(url);

 

The UI Action triggers, but it will not load my URL

action.setRedirectURL(url); works from my UI page ClientsScript but not from the UI Action.

 

Is there another way to solve this. 

Showing a dialog in not an option. 
A new window could work, but preferable the main window. 

 

 

14 REPLIES 14

Bhawana Upreti
Tera Guru

Hi,

Can you please confirm that you are using your UI action on server side as action.setRedirectURL() is a server side function. But, if you are using UI action on client side  you either need to manipulate window.location object or enhance your UI Action and make it capable of executing both client-side and server-side code.

 

If the response is useful, mark the post correct and helpful.

Thanks.

Stewe Lundin
Mega Guru

Ok to summarize this;

 

I have a UI Action adding av button on a form;
The button works fine and triggers this i the script as of now... 

function show_print_dialog(){
	
	var status_report = g_form.getValue('number');
	var url = 'https://axtest.service-now.com/nav_to.do?uri=%2Fui_page.do%3Fsys_id%3D4189bcecdb85df40f439b6bffe961996'; 
	alert(url);
	
    window.location = url;
	//location.href = url;
	//alert('ping');

}

Using windows.location or location.href results in that the page reloads but i ends up on the page;
https://axtest.service-now.com/navpage.do
find_real_file.png
The https://axtest.service-now.com/navpage.do

And it's blank. 

Im expecting it to show my page 

https://axtest.service-now.com/nav_to.do?uri=%2Fui_page.do%3Fsys_id%3D4189bcecdb85df40f439b6bffe961996


I have tried 
action.setRedirectURL() and that don't trigger at all. 

 

Hi,

 

Did you write the name of your function on UI Action--On click field. When you make the Client true, On click field get visible. See the screen shot and do the same. If it still not works for you, can you please provide the snippet of your UI action.

find_real_file.png

Thanks.

Hi,

Try with below URL. You have added extra after uri=.

https://axtest.service-now.com/nav_to.do?uri=ui_page.do%3Fsys_id%3D4189bcecdb85df40f439b6bffe961996

location.href = url;

 

Is alert is working?

 

Thanks

Hi,

Below is action what I did.

 

find_real_file.png

find_real_file.png

When I click button it redirect me to portal home page.

 

find_real_file.png

 

Thanks