UI Action to redirect to portal within the native content frame

Vismit Ambre
Giga Guru

Hi Experts,

I am working on a functionality to direct to a custom made service portal when a button (UI Action) is clicked. Below are the things I have tried:

1. action.setRedirectUrl("/nav_to.do?uri=/cc3");

2. action.setRedirectUrl("/nav_to.do?uri=%2Fcc3");

3. action.setRedirectUrl("/nav_to.do?uri%3D%2Fcc3");

All the above approaches had the client checkbox unchecked (set to false). I also have tried checking the client checkbox (set to true). Adding an appropriate function name in the "Onclick" along with changing the way of redirection from action.setRedirectUrl to window.location.href. But no luck.

 

I am aware that if I modify the URL from "instancename.service-now.com/nav_to.do" to "instancename.service-now.com/nav_to.do?uri=/cc3" then the appropriate PORTAL page is being redirected to withing the native servicenow content frame. But somehow, if I try to accomplish the same using UI action, that doesn't work.

 

Any inputs with respect to this would be highly appreciated.

 

Regards,

Vismit

1 ACCEPTED SOLUTION

Rupam_39
Giga Guru

Hi Vismit,

Try this

I have use this on my incident table to view the "kb_view2" page. With client = checked and OnClick = "goToPortal()" 

function goToPortal(){
	
	var portalName = "/myportal?id=kb_view2"; //Replace with your own url. Make sure the portal doesn't contain header otherwise it will not look good
	g_navigation.open(portalName);
}

Let me know if it works out for you. It was to my surprise that window.open(url, '_top') was not working 

NOTE: This worked for me on instance with Orlando Release. 

View solution in original post

9 REPLIES 9

Rupam_39
Giga Guru

Hi Vismit,

Try this

I have use this on my incident table to view the "kb_view2" page. With client = checked and OnClick = "goToPortal()" 

function goToPortal(){
	
	var portalName = "/myportal?id=kb_view2"; //Replace with your own url. Make sure the portal doesn't contain header otherwise it will not look good
	g_navigation.open(portalName);
}

Let me know if it works out for you. It was to my surprise that window.open(url, '_top') was not working 

NOTE: This worked for me on instance with Orlando Release. 

Hi Rupam,

 

Thanks for that input. Some modifications to your code got it working for me.

 

Changes:

g_navigation.open was somehow still giving me the page as blank. But, g_navigation.reloadWindow() and then g_navigation.open() did the trick for me!

 

Regards,

Vismit

Great. Nice... Post the code
So that it would be helpful for everyone.

Vismit Ambre
Giga Guru
function goToPortal(){
	var portalName = '/ext?id=proposed_change_v3&table=' + g_form.getTableName() + '&sys_id=' + g_form.getUniqueValue() +  '&view=portal&edit_from=ci';
	g_navigation.reloadWindow();
	g_navigation.open(portalName);
}

Vismit Ambre
Giga Guru

This is the code that worked for me:

function goToPortal(){
	var portalName = '/ext?id=proposed_change_v3&table=' + g_form.getTableName() + '&sys_id=' + g_form.getUniqueValue() +  '&view=portal&edit_from=ci';
	g_navigation.reloadWindow();
	g_navigation.open(portalName);
}