- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2020 06:53 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2020 07:57 AM
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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2020 07:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2020 08:13 AM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2020 03:46 AM
Hi
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2020 04:19 AM
Hi
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2020 04:45 AM
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?