Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Standard Change State Management

NilanjanB
Tera Expert

Dear Experts, 

 

I have standard changes which processes the decommission of the servers but the tasks that are created is controlled which means that the preceding task is dependent on the previous task.. but when the first task is closed after the change is moved to implement before the next task is opened, and the state changes to Review but the tasks have not even been populated and there are other tasks pending as well. It is an out of the box behaviour, but how to prevent that. Please help!!!

1 ACCEPTED SOLUTION

NilanjanB
Tera Expert

I worked on the business rule it worked to held on the implement state  

(function executeRule(current, previous /*null when async*/ ) {
    var review_value = '0';

    // Add your code here
    var activeTask = new GlideRecord("change_task");
    activeTask.addQuery("change_request", current.sys_id);
    activeTask.addQuery("state", "NOT IN ", "3,4,7");
    activeTask.query();
    if (activeTask.hasNext()) {
        current.setAbortAction(true);
        return;
    }
    var activeFlow = new GlideRecord("sys_flow_context");
    activeFlow.addQuery("source_record", current.sys_id);
    activeFlow.addQuery("state", "IN", "IN_PROGRESS,WAITING,QUEUED");
    activeFlow.query();
    if (activeFlow.hasNext()) {
        current.setAbortAction(true);
        return;
    }
    current.state = review_value;

})(current, previous);

  

View solution in original post

6 REPLIES 6

Dr Atul G- LNG
Tera Patron

Please check the standard change flow mate

****************************************************************************************
Regards
Dr Atul G. - Learn N Grow Together ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
******************************************************************************************

Thank you @Dr Atul G- LNG  we have designed it that way as I explained in my question.. and I also told that if the change does not find a task in a open state the standard change will move to review which is a OOB behaviour so I need to know what can be done to prevent the change to move to review until all the change task are complete.

https://www.servicenow.com/community/itsm-forum/change-request-unable-to-be-moved-to-review-until-al...

 

Look here mate [Wait for condition]

 

https://www.youtube.com/watch?v=nYdhLaX2EOo&t=9

 

****************************************************************************************
Regards
Dr Atul G. - Learn N Grow Together ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
******************************************************************************************
If you want to support me then buy me a coffee- https://www.buymeacoffee.com/saaswnow This is ServiceNow Flow Designer Training. ServiceNow has been marketing themselves as low code platform and in one of the recent release they came up with flow designer feature which has totally changed the way

I have wait for condition but wait for condition is something that is used on the state and the other task opens when the previous task is closed... see how this flow is
- CI update happens and the first task closed which triggers the second task once the first task is closed and then the consecutive tasks are open and wait for condition is applied on between tasks... but standard change thinks that once a task closes there are no other tasks and immediately moves the change state to review which i need to force stop at the first task and themn move to review when the last task is closed I am thinking of a business rule