Ad hoc tasks closed incomplete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 09:45 AM
Hi All,
Looking for some guidance. We have a few request workflows in our company that our Service Desk regularly have to raise "ad hoc tasks" during the lifecycle of the fulfilment should they require other teams to be involved. We have a "wait for" defined so that the request item will not close until all tasks are completed.
What we have only just noticed is that should multiple tasks be raised and one has the state changed to "Closed Skipped" or "Closed Incomplete" it will set this as the status on all tasks (even those in an opened state) and cancel the workflow.
Our goal is to have the workflow behave in such a way that no other tasks are affected by changing the state of just one and that the RITM would be the same, only if all were skipped or incomplete should the RITM be cancelled. Screenshot of a partial workflow is below with callouts to the "Wait for" and "Script".
Any help appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 07:02 PM - edited 03-17-2023 07:04 PM
I have something similar. This is what is in my wait for condition.
var gr = new GlideRecord('sc_task');
gr.addEncodedQuery('request_item=' + current.sys_id + '^active=true');
gr.query();
if (!gr.next()) {
answer = true;
}
Then I have an if instead of a run script to check if any task was close include. If not it goes down the yes path where I use set value activity to set state = 3 and stage = complete. If no it goes to a different set value activity that set the state = 4 and stage = request cancelled.
Here is the code for the if activity.
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sc_task');
gr.addEncodedQuery("request_item=" + current.sys_id + "^state!=4");
gr.query();
if (gr.next()) {
return 'yes';
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 03:46 AM
Hi Brian,
Thanks for that, I can see the logic but in this particular workflow we are working differently. Our idea is that as long as 1 task is closed complete then we deem the entire request to be completed and successful.
Essentially what flagged it to us as an issue was that someone created an ad hoc task but then realised they didn't need it as it was duplication, so when they marked it as incomplete it marked all tasks as closed incomplete and the request as cancelled.
This then of course triggered a user notification which prompted a negative response. We pretty much just need an IF statement that says if one task is closed complete mark the request as such.
Regards
Brad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 07:57 AM
An if like this should work.
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sc_task');
gr.addEncodedQuery("request_item=" + current.sys_id + "^state=3");
gr.query();
if (gr.next()) {
return 'yes';
}
return 'no';
}