Opening URL on same window / Tab in Mobile Interface?

vineetk
Giga Contributor

Hello Everyone,

I am trying to redirect a URL by using action.serRedirectURL(url);

But when I use this function in UI action it redirects me to the specified URL but into a new window / Tab and not in the same window.

I want, it to open in same window / tab.

Please let me know your suggestions on same.

Thank You

Vineet

1 ACCEPTED SOLUTION

vineetk
Giga Contributor

Hello Everyone,



Got the reason why I was getting redirected to new tab / window.


Earlier I was using the below url for redirecting:



var url = "https://<instance-name>/$m.do#/form/sc_req_item/"+current.sys_id+"/sysparm_view=Mobile";


action.setRedirectURL(url);



But instead, have to use the URL in the following form and which helped me to redirect on the same tab / window.



var url = "#/form/sc_req_item/"+current.sys_id+"/sysparm_view=Mobile";


action.setRedirectURL(url);




i.e. just the url from "#/form" excluding the <instance-name> part.




Thank you


View solution in original post

9 REPLIES 9

bernyalvarado
Mega Sage

Hi Vineet,



Have you tried using window.location.href ?



Thanks,


Berny


Hi Berny,



Yes, I have tried "window.location.href", but it seems "window" function doesnt work in case of mobile UI Actions.



Thank You


Regards


Vineet


Ah ok. I guess your UI action is a server one.



Have you tried doing a redirect using the glideRecord of the record you will like to redirect to?



To direct a user to a record, use this syntax, where new_record is the variable name for the GlideRecord:



action.setRedirectURL(new_record);


Source: http://wiki.servicenow.com/index.php?title=UI_Actions#Using_a_UI_Action_to_Redirect_to_a_URL




Thanks,


Berny


If that doesn't work, then you may want to try switching your UI action to be a client one



I hope this helps.



Thanks,


Berny