- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 11:38 PM
Trying to make a change unable to be moved from implement to review unless all tasks are closed. I created a Dictionary override on the state so the state field is read only. This allows only the UI action to be used to progress the change. Im stuck trying to figure out how to block the change from progressing unless all tasks with this change are closed.
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 11:46 PM
Hi,
you can use before update BR on change_request
Condition: State Changes From Implement AND State Changes To Review
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var cTask= new GlideRecord("change_task");
cTask.addQuery("change_request",current.getValue("sys_id"));
cTask.addActiveQuery();
cTask.query();
if(cTask.hasNext()){
gs.addInfoMessage("your message to show to user");
current.setAbortAction(true);
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 11:47 PM
Hey,
You can have a before update BR, in which you can keep condition as State changes to Review, and in the script you can glide the change tasks table to check if there is any active record or not.
Sample script:
var changeTasks = new GlideRecord("change_task");
changeTasks.addQuery("change_request", current.getUniqueValue());
changeTasks.addActiveQuery();
changeTasks.query();
if(changeTasks.next()){
gs.addInfoMessage('Change task/tasks are still active.');
current.setAbortAction(true);
}
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 11:46 PM
Hi,
you can use before update BR on change_request
Condition: State Changes From Implement AND State Changes To Review
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var cTask= new GlideRecord("change_task");
cTask.addQuery("change_request",current.getValue("sys_id"));
cTask.addActiveQuery();
cTask.query();
if(cTask.hasNext()){
gs.addInfoMessage("your message to show to user");
current.setAbortAction(true);
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 11:47 PM
Hey,
You can have a before update BR, in which you can keep condition as State changes to Review, and in the script you can glide the change tasks table to check if there is any active record or not.
Sample script:
var changeTasks = new GlideRecord("change_task");
changeTasks.addQuery("change_request", current.getUniqueValue());
changeTasks.addActiveQuery();
changeTasks.query();
if(changeTasks.next()){
gs.addInfoMessage('Change task/tasks are still active.');
current.setAbortAction(true);
}
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar