- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2016 05:36 AM
I want to develop a workflow such a way that i want my workflow to wait till one task is Resolved/Closed complete and then move to next task.
I'm trying to achieve this with a "wait for condition" since i also want to check the state = Resolved.
Also what happens is when i Resolve one task it "Resolve" my RITM as well it did not wait for another task to get generated but as per i requirement i want my RITM not to get resolved / closed until all my tasks are resolved / complete
I'm not sure whether the issue is clear let me know if you require more details
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2016 07:43 AM
yes I know that, What you have mentioned in the question was "I want to develop a workflow such a way that i want my workflow to wait till one task is Resolved/Closed complete". So this can do that trick if closed complete is fine.
If you want to query only based on the resolved state then wait for condition should be used.
Slightly modify your code like,
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gr.query();
gs.log('TASK1 count:'+gr.getRowCount());
while (gr.next()) {
gs.log('TASK1 state:'+gr.state);
if(gr.state != 6)
{
gs.log('TASK1 inside if');
answer = true;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2016 06:16 AM
Hi Sajin,
To wait till one task is Resolved/Closed complete .
Check the checkbox in catalog task 'Wait for completion'. If checked, the workflow activity waits for the task to complete before continuing. If not checked, the task is created but the workflow proceeds.
Task Activities - ServiceNow Wiki
For Request item to be closed until all my tasks are resolved / complete , try the below code in a wait for condition before the end activity along with a set value activity to mark the request item as completed:
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2016 07:31 AM
Hi Ajai,
'Wait for completion' works only when the task is closed complete it doesn't allow the workflow to process when the state is Resolved.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2016 07:43 AM
yes I know that, What you have mentioned in the question was "I want to develop a workflow such a way that i want my workflow to wait till one task is Resolved/Closed complete". So this can do that trick if closed complete is fine.
If you want to query only based on the resolved state then wait for condition should be used.
Slightly modify your code like,
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gr.query();
gs.log('TASK1 count:'+gr.getRowCount());
while (gr.next()) {
gs.log('TASK1 state:'+gr.state);
if(gr.state != 6)
{
gs.log('TASK1 inside if');
answer = true;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2016 08:11 AM
Hey Ajai,
Thanks Bro that worked for me
Now i just want to make sure my RITM "state remains in "Open " till my second task is marked closed complete.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2016 08:56 AM
Ajai,
I changed the RITM state via a run script .
Thanks for your help.