How to cancel the RITM, when one of its task is close cancelled?

Sheenu Mejo
Mega Contributor

I need to close the whole RITM and tasks when one of its tasks assigned to a specific group is close canceled.

Please put up your suggestions here.

1 ACCEPTED SOLUTION

Thanks a lot for your replies and responses Brad. As you said, yeah it worked for me. I used the following script in my "wait for condition" activity.

answer = true;
workflow.scratchpad.flag = false;
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.sys_id);
gr.query();

var state;
var group;

while (gr.next()) {

state = gr.getValue('state');
group = gr.getDisplayValue('assignment_group');

if (group.startsWith("HR") && (state == 7)) {
workflow.scratchpad.flag = true;
answer = true;
break;
} else if (!((state == 3) || (state == 4) || (state == 7))) {

answer = false;

}
}

View solution in original post

14 REPLIES 14

Sheenu Mejo
Mega Contributor

Brad Bowman
Kilo Patron
Kilo Patron

Assuming your wait for activity is waiting until all of the tasks are closed, you'll want to fix your script as follows

var result = 'no';
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.sys_id); //returns all of the tasks for the current RITM
gr.query();
while(gr.next()){
var state = gr.getValue('state');
if(state == 4){ //replace with the value of your 'closed cancelled' state
result = 'yes';
}
}
return result;

 

Hi @Brad Bowman,

I tried the above script after my wait for condition script. Have given my wait for condition script below:

answer = true;

var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.sys_id);
gr.query();

var state;

while (gr.next()) {
state = gr.getValue('state');
if (!((state == 3) || (state == 4) || (state == 7))){
answer = false;
}
}

Doesn't work.

Hi @Brad Bowman ,

I tried the above code after my wait for condition activity. Have provided the wait for condition script I used here:

answer = true;

var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.sys_id);
gr.query();

var state;

while (gr.next()) {
state = gr.getValue('state');
var group = gr.getDisplayValue('assignment_group');
gs.log("group is " +group);
if (!((state == 3) || (state == 4) || (state == 7))){
answer = false;
}

}

 

Doesn't work after this.

Is the wait for code working correctly - is the workflow entering the If activity after, and only after all tasks have been closed complete, incomplete, or skipped, or is the workflow going to the If activity too soon, or not at all?