What's the alternative for setRedirectURL in the new Service Portal?

Kevin Chung
Giga Guru

Hi guys

I'm trying to set up a UI action button to redirect the user to a different URL in the service portal.

Traditionally, I would use the setRedirectURL method for this.. but this doesn't seem to work anymore in the new service portal!

I've digged up the documentation and found..

UI Actions

All Server-side UI Actions are supported, with one important distinction - setRedirectURL() operations are ignored, due to the fact that Service Portal forms do not handle redirection the same way that forms in the platform do.

this is from documentation/form.md at 7ff41f14c1b9e2525347160577b322300b7ed5a3 · service-portal/documentation ·...

If so, then what's the alternative way to redirect the user to a different URL?

Please share if you know.. Thanks

Regards

Kevin

8 REPLIES 8

Jaspal Singh
Mega Patron
Mega Patron

Hi Kevin,

 

You can try using window.location='url'; in client part of UI Action.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

smruti
Kilo Contributor

Hello jaspal,

I have tried using window.location but it is giving below error.

 

find_real_file.png

Read somewhere that window is null for Service Portal & hence it fails.

 

Can you try top.location . Alternatively you may refer thread.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

Chuck Tomasi
Tera Patron

Here's the way I do it. Not sure if it's officially correct, but hey - it works!

 

In the client script, I use:

	$scope.goToUrl = function(url) {
		$location.url(url);
	}

In the HTML, I have a button with an ng-click that looks like this to go to the next record:

  <button class="btn btn-primary"s ng-click="goToUrl(data.nav.prev)">
    <span class="myDefault glyphicon glyphicon-arrow-left"></span>
  </button>

 

The data.nav.prev is calculated in the server script by a script include function, but it ultimately comes out as a relative URL. e.g. ?id=some_widget?sysparm_foo=bar.