Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

ServicePortal redirect URL

Salzo
Giga Contributor

Hello,

 

I am trying to change the ootb simple list widget to redirect the user a webpage outside servicenow.

 

At the moment when I click the link I want to trigger the redirect instead of going to https://www.newurl.com the user is being sent to http://instance.service-now.com/www.newurl.com.

 

So far I have tried

 

gs.setRedirect(url);
location.href(url);
$location.href(url);

$location.path(url);

 

 

How do I do this?

8 REPLIES 8

Allen Andreas
Tera Patron

Hi,

Just to clarify, you're using a simple list widget to redirect to an outside URL?

Any particular reason why you need to use a simple list widget when not directing them to an actual list...contained on your instance?

Could you use a different widget, say an Icon Link or something instead?


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

bardakov
Tera Expert

try on the client side script 
window.location.href = 'your_url';

Anais Geisen
Tera Expert

Hello,

Could you please send the exact code and where did you put it? (server/client/link part of the widget?)

Also, do you have any console error?

Normally, you should achieve this with $location.url(url); (do not forget to check if $location is part of the parameters of your script).

 

Regards,

Anaïs

 

 

Hello,

 

No errors no,

(do not forget to check if $location is part of the parameters of your script).<- how would I check this

 

 

 

 

function ($scope, $location, $rootScope, spUtil, $interpolate) {
var c = this;

this.data.filterText = "";
this.showFilter = false;

this.onClick = function($event, item, url, action) {
$location.href(url)

}
this.getMaxShownLabel = function(maxEntries, totalCount) {
if (totalCount == c.data.maxCount)
return "${First [0] of more than [1]}".replace('[0]', maxEntries).replace('[1]', totalCount);

return "${First [0] of [1]}".replace('[0]', maxEntries).replace('[1]', totalCount);
};

c.getActionColor = function(action) {
return "text-" + action.color;
};

c.update = function update() {
c.server.update();
}

c.toggleFilter = function() {
c.showFilter = !c.showFilter;
}

}