gs.setRedirect() in combination with current.setAbortAction(true) not executed (Before/Update BusinessRule)

Meloper
Kilo Sage

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.

 

11 REPLIES 11

Ankur Bawiskar
Tera Patron

Hi,

Are you saying the below line doesn't reload the form after aborting

gs.setRedirectURL(current);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Yes, there is no Action with this command

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Indrajit
Mega Guru
Hey Meloper,
 
Try using 
action.setRedirectURL(current); 
i hope it will work in your Business rule.
you can refer below thread for gs.setRedirectURL(current) and action.setRedirectURL(current)
 
 

kindly mark Correct and Helpful if applicable.

Regards,

Indrajit.