Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Redirecting to another widget from Portal Widget

DPrasna
Tera Contributor

Hello All,

I have a Portal Widget which has to redirect to another widget.

Right now I use the below code:

var url = "https://dev112799.service-now.com/sp/?id=demo_widget_for_manage_acc&ci="+ci+"&env="+env;

I have hard-coded the URL, how to use the property instead to dynamically fetch and redirect from the URI?

Full code below

 

var url = "https://dev112799.service-now.com/sp/?id=demo_widget_for_manage_acc&ci="+ci+"&env="+env;
		//var url =  gs.getProperty('glide.servlet.uri') +"sp/?id=demo_widget_for_manage_acc&ci="+ci+"&env="+env;
		c.data.tempname = c.fname;		
		$rootScope.customEvent=ci;
		top.window.location =url;

TIA,

D  

2 REPLIES 2

Arpitha Gopalsw
Giga Guru

Hi D,

 

Try the below way:

 

In Server Code:

data.instance_url = gs.getProperty('glide.servlet.uri');

In HTML Template:

<a target="_blank" href="{{c.data.instance_url}}$sp.do?id=demo_widget_for_manage_acc&ci="+ci+"&env="+env>

 

OR

 

 Directly call you other widget as below:

 

In Server Side:

data.xyz_widget = $sp.getWidget("<Name of your widget>");

 

In HTML Template:

<div class="col-xs-12 col-md-10 top-pad"
<sp-widget widget="c.data.xyz_widget"></sp-widget>
</div>

 

Let me know if this works!

 

Regards,

Arpitha G

DPrasna
Tera Contributor

How to do from client side as I have it in my existing script because I have to change the other HTML and Server side script which may disrupt other codes