Navigate to one widget to another Service Portal

DB1
Tera Contributor

Hello All, 

I am looking for help with the following request.

I have displayed some list of CIs using the following code in a widget

But whenever a record is selected out of the list I want that to redirect to a new Widget (on click of the record).

How to acheive that?

Window url is not going to work. how to make it work on selection of the record from the list

find_real_file.png

<div class="panel panel-primary">  
  <div class="panel-heading">
  <h1 class="bg-primary">Client CIs  
  </h1>
</div>
  <ul class="list-group result-container">
    <li ng-repeat="inc in data.incident" ng-model = "c.fname" ng-click="c.openPopUp">
      <a href>{{inc.ci}}</a>
        
    </li>
  </ul>
  </div>
 
<!--<sp-widget widget="data.example"></sp-widget> --
(function() {
	/* populate the 'data' object */
	/* e.g., data.table = $sp.getValue('table'); */
data.incident=[];
data.user = gs.getUserID();
	var gruser_list = new GlideRecord('cmdb_rel_person');
	gruser_list.addQuery('user',data.user);
	gruser_list.query();
	var results = [];
	while(gruser_list.next())
	{
		var inc = {};
		//inc.user = gruser_list.getDisplayValue('user');
		inc.ci = gruser_list.getDisplayValue('ci');
		data.incident.push(inc);
	}

//data.example = $sp.getWidget('demo', {});
})();

I have a widget to display some set of CIs

function($scope, $rootScope){
	var c = this;
	c.test = function()
	{
		c.data.tempname = c.fname;
		var test = c.data.tempname;
		alert(test);
		$rootScope.$broadcast('xyz',test);//key - value function
	//data.example = $sp.getWidget('demo', {});
		c.openPopUp = function() {
var url = gs.getProperty() +"/sp";
var popup = window.open (url, "popup", "width=900, height=600");
}
	}
}

 

 

1 ACCEPTED SOLUTION

you need to replace the ng-click to below.You missed the paranthesis 

ng-click="c.openPopUp()"

View solution in original post

6 REPLIES 6

Mohith Devatte
Tera Sage
Tera Sage

hello,

you can use top.window.location like below 

var url ="your_url";

top.window.location =url;

 

Hope this helps 

please mark my answer correct if this helps you

Hello Mohith,

Thanks for the reply

It is a custom widget 2 I created the above one is custom widget 1. Which URL should I put in?

you need to put the URL of the custom widget 2 .

Because on click of a record in custom widget one you need to redirect them to custom widget 2 .

so in url put custom widget 2 one

I tried it didn't work. Am I doing something wrong

Client:   

var url ="https://dev113490.service-now.com/sp_widget.do?sys_id=ea53b2f31b2551106eeda793604bcb2";
        top.window.location =url;

I even made the Widget Public still didn't work

HTML

</div>
  <ul class="list-group result-container">
    <li ng-repeat="inc in data.incident" ng-model = "c.fname" ng-click="c.openPopUp">
      <a href>{{inc.ci}}</a>
        
    </li>
  </ul>
  </div>