Wait for all tasks to be closed completed.

Naresh291
Tera Contributor

Hi ,

I have a workflow that kicks out three tasks . My requirement is to have all three tasks closed after which the request would be set to closed complete .

I was thinking about Wait for condition , but not sure how to use it .

Can anyone please provide me with ideas/script for implementing this .

 

Regards,

Naresh

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Naresh29 

you can use after update BR on sc_task when task is completed to close RITM and REQ

Condition: Active Changes to False

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here

	var gr = new GlideRecord('sc_task');
	gr.addQuery('request_item', current.request_item); 
	gr.addQuery('active', true);
	gr.query();
	if(!gr.next()){
		var ritm = current.request_item.getRefRecord(); 
		ritm.state = 3;
		ritm.update();
		
		var req = current.request.getRefRecord();
		req.state = 3;
		req.update();
	}

})(current, previous);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Kajal Goti
Mega Guru

Hi,

 

Are you creating all 3 task at a time ? If yes you can use join activity in workflow 

Are you creating task one by one using catalog task activity ? in this case catalog task activity having this capability Wait for Condition you can check this

 

Are you creating task one by one using script? in this case at the end of all task take one run script and mark those task  close complete and then set the RITM close complete

 

Let me know if you have any query

 

Please mark as correct/Helpful, If you find any help