setAbortAction(true) no tab/page refresh in SOW

sarah_kovar
Tera Contributor

I've noticed that in Before Business Rules that use setAbortAction(true), there IS a page refresh in Platform; however, there is NOT one in SOW/Service Operations Workspace. This seems to be expected behavior, as I compared to my PDI. I was wondering if folks have done anything to address this in SOW? Or just accept that is expected behavior? It's nice to have the page refresh in Platform. I understand I could do an onSubmit client script. I don't want to at this time. 

Thanks!

Sarah

1 REPLY 1

Timo Globisch
Tera Contributor

Hi Sarah,

we have the same behavior in CSM/FSM Configurable Workspace. I found this Community Post: https://www.servicenow.com/community/spm-forum/new-project-workspace-unexpected-behavior-of-some-bus...

Seems like it is expected behavior in the new workspaces.

 

My issue with a Business Rule containing current.setAbortAction(true) is that it affects Info/Error Messages in our Workspace. They are not displayed correctly after saving. My workaround for it: instead of using setAbortAction, I just set the values back to previous.

 

Example: This Business Rule checks if a User is the only active User in an Approval Group, if he is, deactivation of the User is "aborted" with error messages:

 

Filter Condition: activeCHANGESTOfalse^ORlocked_outCHANGESTOtrue
Script:
(function executeRule(current, previous /*null when async*/ ) {

    // When a User is deactivated, search for membership in any Group with Type Approval
    var grGroupMember = new GlideRecord("sys_user_grmember");
    grGroupMember.addEncodedQuery("group.typeLIKE0093966188673d54b107bf8c30a24d53^user=" + current.sys_id);
    grGroupMember.query();

    // Check for every membership if there are other active members
    while (grGroupMember.next()) {

        var grOtherMembers = new GlideRecord("sys_user_grmember");
        grOtherMembers.addEncodedQuery("group=" + grGroupMember.group + "^user!=" + current.sys_id + "^user.active=true^user.locked_out=false");
        grOtherMembers.query();
        // If there are other members, do nothing
        if (grOtherMembers.next()) {
            // do nothing                      
        } else { // If there are no other members, show error message depending on roles and abort update

            // Get State which has the Approval Group set
            var grState = new GlideRecord("custom_states_table");
            grState.addQuery("approval_group", grGroupMember.group);
            grState.setLimit(1);
            grState.query();
            if (grState.next()) {

                if (gs.hasRole("custom_agent_role")) {
                    gs.addErrorMessage(gs.getMessage("approval group only member deactivated agent", grState.u_name));
                } else {
                    gs.addErrorMessage(gs.getMessage("approval group only member deactivated customer", grState.u_name));
                }
            }
 
            // This was my first attempt, but didn't work properly
            // current.setAbortAction(true);
 
            // This works just fine for my purpose:
            current.active = previous.active;
            current.locked_out = previous.locked_out;           
 
        }
    }

})(current, previous);