Business Rule to abort action not redirecting back to same record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2016 03:43 PM
I have a Business Rule running during update, with "When" as "Before", on the the sc_task table:
(function executeRule(current, previous /*null when async*/) {
if(current.variables.offboard_desktoprecoverassets == '' && current.state == "3"){
current.state=previous.state;
current.setAbortAction(true);
gs.addInfoMessage('NOTICE: Please select an option for desktop recovery below completing the task.');
gs.setRedirect(current);
}
})(current, previous);
Everything seems to working as the state changes back to Open (the previous state on a new catalog task), the info message comes up on the screen, but my redirect is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2016 04:13 PM
Hi ShaneCossever,
This is a known issue (PRB604580). gs.setRedirect() in combination with current.setAbortAction(true) not executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2016 04:16 PM
Do you know of a workaround?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2016 03:30 AM
I think, you can set all the fields to their old values and simply redirect with the error message. This will prevent any value change triggers in the system and might serve the purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 05:21 AM
Hello
You can fix this using URL address (tested on Newyork). The code can be similar to:
var url = gs.getProperty("glide.servlet.uri") + gs.action.getGlideURI();
gs.addErrorMessage("Error message");
current.setAbortAction(true);
gs.setRedirect(url);
Thank you