Workflows - branching and joining

perlguy
Kilo Explorer

Am I doing this correctly?

I am BRANCHing out and creating 2 (or more) tasks - works fine.

Once all of the tasks have been completed/closed, I then want to continue with the workflow. So, I used a JOIN to bring the tasks back together.

The problem I have is that the stuff after the JOIN (log messages & notification) never seem to get sent.

In the system logs, I see:


2013-06-06 09:45:55InformationCreated task to create Name Badgeworkflow
2013-06-06 09:45:55DebugRunning activity The join: "update"workflow
2013-06-06 09:45:55DebugCreating activity Name Tagworkflow
2013-06-06 09:45:55DebugRunning activity The join: "activityComplete"workflow
2013-06-06 09:45:55DebugCreating activity The joinworkflow
2013-06-06 09:45:55DebugRunning activity ADMINISTRATIVE - Create Name Tag: "update"workflow
2013-06-06 09:45:55InformationTerminating context: 6464c761913d0500cd217ca6439f58e4, state: finishedWorkFlow


So, it looks like the workflow "state" is finished, but I don't get anything after the JOIN - even though it appears to perform the JOIN.

I am sure that this is simple too, once you get the hang of it!

Thanks!

Brent
5 REPLIES 5

Mark Laucus
Giga Guru

I have always had different outcomes using Branch and Joins in workflows. One suggestion is to remove the Incomplete action on the Join object if you are not using it. Just right click on that action and a dialog box will show with actions include delete.

Looking at your workflow, you could remove the Branch and Join activity all together. Instead of the Branch object, perform the actions that drop straight through (administrative task and log) and then follow it up with the IF object and the following actions. If want to run the tasks at the same time and wait until they are all finished, you can a script object with the following code to check all the task are done before moving on.



// Set the variable 'answer' to true or false to indicate if the condition has been met or not.
//Query for all tasks to see if they are inactive
var rec = new GlideRecord('sc_task');
rec.addQuery('request_item', current.sys_id);
rec.addQuery('active', true);
rec.query();
if(rec.hasNext()){
answer = false;
}
else{
answer = true;
}


Good luck,


Would I have to have this code run on a timer to check every few minutes if the tasks are done?


It is more of a stop point and just monitors itself to check the values. Where I got this from is to do the same affect for change tasks to make sure they complete before closing a change.


This is a Wait for Condition Object that you would use. But insert the script that I posted earlier and it will wait until it is true (all the tasks closed). Sorry for the confusion.