RITM record closed even though it had open tasks

Amelie G
Kilo Expert

Hi all,

We've got an issue raised by a customer where the requested item record is getting closed when manual tasks are closed even if there are other active tasks. They want the requested item to get closed only when all tasks are closed, but they also want the option to manually close the RITM even if it has active tasks (not best practice though).

A solution would be to check if there are remaining active tasks when a task is set to close complete and if there are, don't set the state of the requested item to closed complete. However, I'm not sure how to achieve this. I've compared the workflow with the one in my PDI and they are the same, and OOTB behaviour is that the RITM should close when all tasks are closed - this works fine on my instance but not on the customer's. Could someone please help me with this, all ideas are welcome!

Thanks

1 ACCEPTED SOLUTION

They want to be able to close RITMs with open tasks (in this case, only the state changes to closed complete but the stage will be complete only when all tasks are closed - they shouldn't do this anyway but they are not following the right process). But they have this issue where whenever you close one manual task, the state/stage of the requested item moves straight to closed complete even with other tasks left.

I've actually tried something and it seems to be working. I've added a new activity called Wait for Condition that goes after Wait for Task to Complete. I've used this code in the script and it seems to be working:

var tskRec = new GlideRecord("sc_task");
tskRec.addQuery('request_item', current.sys_id);
tskRec.addQuery('active', "true");
tskRec.query();
if (tskRec.next()) {
    answer = false;
} else {
    answer = true;
}

Thank you for your help!

View solution in original post

7 REPLIES 7

Got it -- yeah the script include function tripped me up at first as well, but the reason your remaining active tasks aren't picked up is because of this key line of code:

rt.addQuery("order",this._wf.scratchpad.taskSeq.data[this._wf.scratchpad.taskSeq.index]);

 So basically it is only checking to see if the specific task where order = current sequence in workflow execution has State = Closed Incomplete.

You may need to go back to your customer and discuss the requirement further. Looking back at your original post, the requirement is contradictory and doesn't seem to be well enough defined to code for:

"They want the requested item to get closed only when all tasks are closed, but they also want the option to manually close the RITM even if it has active tasks (not best practice though)."

If they want the requested item to get closed only when all tasks are closed, then that necessarily means they cannot close the RITM even if it has active tasks.

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

They want to be able to close RITMs with open tasks (in this case, only the state changes to closed complete but the stage will be complete only when all tasks are closed - they shouldn't do this anyway but they are not following the right process). But they have this issue where whenever you close one manual task, the state/stage of the requested item moves straight to closed complete even with other tasks left.

I've actually tried something and it seems to be working. I've added a new activity called Wait for Condition that goes after Wait for Task to Complete. I've used this code in the script and it seems to be working:

var tskRec = new GlideRecord("sc_task");
tskRec.addQuery('request_item', current.sys_id);
tskRec.addQuery('active', "true");
tskRec.query();
if (tskRec.next()) {
    answer = false;
} else {
    answer = true;
}

Thank you for your help!

I was originally thinking a Wait for Condition as well, but the reason I didn't recommend that approach is the Wait for Condition in your workflow is only actually evaluated when the requested item is updated in some way. So if a catalog task closes but does not trigger an update to the requested item, then the wait for condition will not be evaluated in the requested item's workflow.

find_real_file.png

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry