Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

workflow should wait until all the tasks are completed

RudhraKAM
Tera Guru

Hello I have a workflow which is creating 2 tasks up on firing , but if one task is closed another task is marked closed in complete , , i searched in community , they mentioned to use wait for WF event , but not sure what to select in that 

I added Wait for completion on both tasks . 

 

there is another scenario where only 1 task will be created , then how to address that , If i use the wait for WF event then as it will be waiting for another task to complete (which is not going to happen as the condition is not satisfied ) 

find_real_file.png

 

 

find_real_file.png

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

var rec = new GlideRecord('sc_task');
rec.addQuery('request_item', current.getValue('sys_id'));
rec.addQuery('state','NOT IN','3,4,7');
rec.query();
if(rec.hasNext()){
answer = false;
}
else{
//Continue
answer = true;
}

View solution in original post

23 REPLIES 23

paw2
Tera Expert

Hi Kam,

 

Try using a Join

 

Patricia

Thanks for that , but in this scenario ,, if the 2nd task is not generated then how to deal with that ? it will be waiting for the 2nd task to be closed which is not happening .

find_real_file.png

Connect the loop from No in If condition to Join

Tried that too 

find_real_file.png