State is not moving back until we refresh it.

Venkat141
Tera Contributor

Hello,

@Ankur Bawiskar 

@Saurav 

@shloke04 

@Anil Lande 

whenever we are trying to move the state then it will check if any open task records are there or not. if there are no-open tasks records then state will move to next state or else it will throw an error and remains on same state. 

 

here Issue is when we are trying to move the state from "perform post test activities" to close and if any open tasks are present then it's throwing an error but state will be close and if we refresh the page then it will go back to "perform post test activities" state.

 

Here in the below code it's working fine for all states expect for close.

 

Could anyone please help me what is the issue.

 

(function executeRule(current, previous /*null when async*/ ) {
    //To check active tasks in each valid state
    var checkTaskAgg = new GlideAggregate('x_nr_it_service_co_itscm_task');
    checkTaskAgg.addQuery('parent', current.sys_id);
    checkTaskAgg.addQuery('active', true);
    checkTaskAgg.addAggregate("COUNT");

    checkTaskAgg.query();
    if (checkTaskAgg.next())
        if (checkTaskAgg.getAggregate("COUNT") > 0) {
            gs.addInfoMessage(gs.getMessage('Please close open tasks from previous state to move to next state'));
            //gs.addInfoMessage('current :'+current.state+'----previous state : '+previous.state);
            current.state = previous.state;
            current.test_status = previous.test_status;
            current.closed_at = previous.closed_at;
            current.closed_by = previous.closed_by;
            //gs.addInfoMessage('final :'+current.state);
            //var url = gs.getProperty("glide.servlet.uri") + gs.action.getGlideURI();
           
            current.setAbortAction(true);
        //  action.setRedirectURL(current);
            //gs.setRedirect(url);
            //gs.addInfoMessage(url);
            gs.addInfoMessage('hello');
            //location.reload();
           
            reloadWindow(window);
            gs.addInfoMessage('hi');
           

        }

})(current, previous);
 
Best Regards,
Pavan

 

5 REPLIES 5

Hermes14
Tera Contributor

Hi, were you able to fix this issue? I'm currently having similar use case to yours. May I know how you fixed this?