- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 03:58 AM
HI All,
We had an issue with few of the RITMs, where RITMs with multiple tasks are not closed even if all their associated catalog tasks are closed. The requirment is to identify all those RITMs by getting them into log and close them.
Note: All those RITMs have multiple tasks each.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 04:57 AM
Run this code in a fix script. Mark as helpful if it helped.
var ritm = new GlideRecord("sc_req_item");
//check for all active RITM
ritm.addEncodedQuery("active=true");
ritm.query();
while (ritm.next()) {
var task_incomplete = 0;
var tasks = new GlideRecord('sc_task');
tasks.addQuery('request_item', ritm.sys_id);
tasks.query();
while (tasks.next()) {
//check is task is ative
if (tasks.active == true) {
task_incomplete = 1;
}
}
//close RITM if all tasks are inactive
if (task_incomplete == 0) {
//close all RITM with no active Tasks
ritm.setValue('active', false);
ritm.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 04:29 AM
Hi,
We also face issue in few items. Even though all the SC tasks are closed, RITM remains as in progress. You can add activity at the end of workflow and set state as complete before it end.
Thank you,
Palani
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 04:57 AM
Run this code in a fix script. Mark as helpful if it helped.
var ritm = new GlideRecord("sc_req_item");
//check for all active RITM
ritm.addEncodedQuery("active=true");
ritm.query();
while (ritm.next()) {
var task_incomplete = 0;
var tasks = new GlideRecord('sc_task');
tasks.addQuery('request_item', ritm.sys_id);
tasks.query();
while (tasks.next()) {
//check is task is ative
if (tasks.active == true) {
task_incomplete = 1;
}
}
//close RITM if all tasks are inactive
if (task_incomplete == 0) {
//close all RITM with no active Tasks
ritm.setValue('active', false);
ritm.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 05:00 AM
This issue could happen if your SCTASKs active flag didn't change to "false" even though their state is Closed Complete or Closed Incomplete or Closed Cancelled. If you debug onto that flag, you can notice this.
System will come to know task's lifecycle end only if it's active flag changed to false. So this could be your root cause.
Check your instance, for any script (probably Business Rule) might have collision with the other script.
Krishna
https://www.linkedin.com/in/mkrishnasundar/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 06:01 PM
WE HAVE SAME issue how can we check if Flag did not change to false ? or debug it ?
do i need to modify Business rule "mark closed" which runs on "task" table which sets the active flag to false