How to correctly use 'JOIN' activity in workflow?

Deepansh Jain1
Kilo Contributor

Hi,

I have a workflow (see attached screenshot) , when all the catalog tasks are closed complete the requested item State should change to closed complete & if any one of the catalog task is closed incomplete the requested item state should be closed incomplete. In order to set the values I have used "JOIN" core activity 

But if I close complete all the tasks the requested item is still "closed incomplete".Can anyone suggest a correct way of using the "JOIN" activity or any other way of completing the workflow?? What should be the correct activity values to run it as expected.

Join output condition on Closed complete node ; activity.result == 'complete'

Join output condition on Incomplete node ;activity.result == 'incomplete'

 

2 REPLIES 2

Ujjawal Vishnoi
Mega Sage
Mega Sage

Hi Deepansh,

Please refer the link below. This will help you to understand about join activity.

https://www.servicenowguru.com/graphical-workflow/workflow-join-activity/

 

Hope this helps,

 

Regards,

Ujjawal

Lukasz Bojara
Kilo Sage

Hi,

In overall, the JOIN activity does not check what was the final result of all branches that it joins. It checks if the activities before it have finished, no matter what the result is. It will result to incomplete is there is a branch that will bypass join.

When looking at your workflow, you should add an IF conditionthat will check if all catalog tasks have closed completed and set the value of the request.

Your workflow could look e.g. something like this.

find_real_file.png

 



And in the IF condition, you would need to write a script to check statuses of catalogue tasks.

answer = allCompleted();

function allCompleted(){
	var grTask = GlideRecord('sc_task');
	var completed = 0;
	var count;
	grTask.addQuery('request_item',current.sys_id);
	grTask.query();
	
	count = grTask.getRowCount();
	
	
	while ( grTask.next() ){
		
		if (grTask.getValue('state') === '3') {
			completed++;
		}
		
	}
	
	return count === completed ? 'yes' : 'no';
}

 

Hope this helped.

Best regards,
Łukasz