What's the alternative for setRedirectURL in the new Service Portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2016 09:27 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 10:36 AM
Did you ever find a solution to this? I am looking to do the same thing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 01:07 PM
Sorry Daniel. No I haven't yet.. Please share if you find one too!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2016 10:29 PM
So, it's a bit of a hack, but here is what I finally got working. It should work for any ui action that is server side and the last thing that it does is simply redirect the user.
First set the action name on the UI Action to begin with url_redirect, such as: url_redirect_create_request.
Create a message in the sys_ui_message table with that key and the URL you want to redirect to as the message.
Clone the Form Widget.
In the triggerUIAction function add the following lines of code:
if(action.action_name.startsWith('url_redirect')){
c.server.get({action: "get_redirect", name: action.action_name, id: $scope.data.sys_id}).then(function(response) {
g_form.addErrorMessage(response.data.redirectURL);
$window.location = response.data.redirectURL;
});
}
Finally in the server script add the following:
if (input && input.action === 'get_redirect'){
data.redirectURL = gs.getMessage(input.name).replace(/current.sys_id/, input.id);
}
this just replaces current.sys_id with the sys_id of whatever form you are looking for, that is all I needed for the couple of UI actions I needed to convert. You could make it more general and generic by adding more information to the message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2018 04:06 AM
Hello Kevin,
Have you got any solution to this?I am looking redirection on service portal through UI action.