gs.setRedirect() in combination with current.setAbortAction(true) not executed (Before/Update BusinessRule)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2020 03:11 AM
Hi,
if a Problem has an active ProblemTask or an active attached Incident, it should not been closed.
I use an on before BR.
current.setAbortAction works but the Form does not reload.
(function executeRule(current, previous /*null when async*/ ) {
//Check for active Problem Tasks of Current Problem
var grPTASK = new GlideRecord("problem_task");
grPTASK.addQuery("problem", current.sys_id);
grPTASK.addQuery("active", true);
grPTASK.query();
if (grPTASK.hasNext()) {
current.setAbortAction(true);
gs.addErrorMessage('Anzahl der Problems gleich' + grPTASK.getRowCount());
gs.addErrorMessage('Anzahl der current state gleich' + current.state.getDisplayValue());
gs.addErrorMessage('Anzahl der previous state gleich' + previous.state.getDisplayValue());
current.state = previous.state;
gs.setRedirectURL(current);
} else {
var grINC = new GlideRecord("incident");
grINC.addQuery("problem_id", current.sys_id);
grINC.addQuery("active", true);
grINC.query();
if (grINC.hasNext()) {
current.setAbortAction(true);
gs.addErrorMessage('Anzahl der Incidents gleich' + grINC.getRowCount());
current.state = previous.state;
gs.setRedirectURL(current);
}
}
gs.setRedirectURL(current);
})(current, previous);
I found many unsolved Question and this KB/Problem:
https://hi.service-now.com/kb_view.do?sysparm_article=KB0539962
We also use some BR with this commands and it works....
So i need a refresh of the Form after the action aborted.
What should i do?
Currently it behaves like this:
The Action aborted and the new Values are on the form. User has to refresh and the Record appears with the previous Values.
But i don#t want that the user has do refresh manually.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2020 03:22 AM
Hi,
Are you saying the below line doesn't reload the form after aborting
gs.setRedirectURL(current);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2020 03:38 AM
Yes, there is no Action with this command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2020 04:46 AM
Hi,
I think no solution exists for this as of now.
Do let us know if you manage to have workaround for this that would be helpful
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2020 03:39 AM
kindly mark Correct and Helpful if applicable.
Regards,
Indrajit.