Change management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 11:37 PM - edited 11-13-2023 02:59 AM
Hi,
if all tasks are open change should not move to review. I tried a BR with code it is updating the closed task to canceled, It is not updating the open tasks to cancel. Can anyone help me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 01:28 AM
Hi @Community Alums ,
Try doing one Business Rule in the Change Task table
With this conditions
And this code in the Advanced Tab
(function executeRule(current, previous /*null when async*/ ) {
var changeTasks = new GlideRecord("change_task");
changeTasks.addQuery("change_request", current.change_request).addCondition("active",true);
changeTasks.query();
while(changeTasks.next()){
changeTasks.state='4';
changeTasks.update();
}
})(current, previous);
This Business Rule will cancel the other change tasks when one is Closed/Canceled
To avoid going to the Review State, add a business in the Change Request table as follow
(function executeRule(current, previous /*null when async*/ ) {
var changeTasks = new GlideRecord("change_task");
changeTasks.addQuery("change_request", current.sys_id).addCondition('active', true);
changeTasks.query();
if (changeTasks.next()) {
gs.addErrorMessage("open tasks which must be closed/canceled before reviewing this change record");
current.setAbortAction(true);
current.state = previous.state;
}
})(current, previous);
If that helps please mark my answer as correct / helpful!
And if further help is needed please let me know
Cheers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 01:39 AM
Hi,
Tried but not working eventhough one change task is closed other change tasks are still in open state.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 01:38 AM
Hi @Community Alums
Greetings!!
I am not sure what is the use case here. Bcz if you cancelled all task then task which are already closed will be moved to cancelled also, cancelling all task means no work done on change, and change marked as cancelled.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
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
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 01:41 AM
Hi,
If work done on one change task, that ctask will set to close , in that case if one change task for a particular change is closed all other change tasks of that particular change should set to cancel.