Fork and join: work in parallel
A purchase order needs Finance and Legal to sign off, and neither should wait for the other. A Fork sends it to both at once, and a Join waits until they have both answered. We opened the parallel sign-off sample, and fixed three things on the way: unreadable labels, stray resize handles, and a Join whose most useful setting had no control.

Most processes are a line: one step, then the next. Some aren't. A purchase order needs Finance and Legal to sign off, and there's no reason for either to wait for the other. Doing them one after the other only makes the order take twice as long.
A Fork splits a run so that both happen at once. A Join brings the run back together.
We used the Parallel Sign-Off sample. Import it from samples/solutions/bpms-parallel-sign-off
to follow along, and open its process, Parallel Sign-Off.
The process

Read it left to right. The order is raised. Ask both at once is the fork: two connections leave it, one to Finance and one to Legal. Each of them either signs off or refuses. Every one of those ways ends at Both have answered, the join. After the join a branch asks whether anybody refused, and the order is marked approved or refused.
A fork and a join are drawn as bars rather than boxes, the way process diagrams usually show them.
Their names used to be unreadable. The title was written across the bar itself, which is only a few pixels wide, so Ask both at once came out as a column of cut-off letters. We moved it under the bar while writing this. The branch Did anyone refuse? had the opposite problem: its description was squeezed into the diamond in tiny type. A diamond now shows only its title, and the description stays in the properties panel.
The fork
Click Ask both at once:

A fork has nothing to set, and that's the point: it does one thing. Every connection leaving it starts its own route, and all of them run at once. Here that means a task in Finance's list and a task in Legal's list, at the same moment.
You'll notice there are no resize handles around the bar. There used to be eight, on every fork, join, start, finish and timer, although none of those shapes can be resized. Only tasks and branches have them now.
The join
Click Both have answered:

Carries on when decides when the run gets past the join:
- Every route has arrived (the default). Both Finance and Legal have answered.
- The first route arrives. For "either of two managers may approve".
- A number of routes have arrived, with How many routes under it. Two of three, say.
When the join carries on before every route has arrived, the routes still going are stopped, and their open tasks are taken out of people's lists. That last part is also new: the routes were stopped, but their tasks stayed in people's lists, where one could still be opened for a route that had ended. We fixed it while writing this.
This choice is new too. The engine has had all three for a while, but the designer showed none of them, so every join waited for everybody unless you edited the process file by hand.
Why four connections arrive and it waits for two
Look at the join again: four connections arrive at it, from Finance sign-off, Finance refused, Legal sign-off and Legal refused. It still waits for two.
That's because a join doesn't count its connections. It counts the routes its fork started. The Finance route reaches it once, whichever way Finance answered, and so does the Legal route. A join that counted connections would wait forever for the two refusals that didn't happen.
That's also why the refusal steps lead to the join and not to a finish of their own. Each is one line of code:
setVariable("refused", true);
A variable is shared by every route in a run, so it's how one route tells the rest of the process
something. The branch after the join reads refused to decide which way to go.
What the problems panel checks
To see what the designer says about a fork on its own, we dropped a second one into the System lane:

- A fork needs at least two ways out, and a join at least two ways in. Anything less has nothing to run in parallel.
- As many forks as joins. A process that splits more often than it merges has a route still going when it should be over.
That last message used to read "There are 2 Forks and 1 Joins". It reads Forks: 2. Joins: 1. now, in every language.
We didn't save any of this. Closing the designer without saving leaves the sample as it was.
The parallel part, as the process stores it
The fork and the join are two nodes with nothing to configure here, and the decision after them is a branch with two conditions:
"nodes": [
{ "id": "node-split", "kind": "fork", "laneId": "lane-buyer", "title": "Ask both at once" },
{ "id": "node-finance-refused", "kind": "task", "taskType": "script", "laneId": "lane-finance",
"title": "Finance refused", "scripts": { "onEnter": "setVariable(\"refused\", true);" } },
{ "id": "node-both", "kind": "join", "laneId": "lane-system", "title": "Both have answered" },
{ "id": "node-decide", "kind": "branch", "laneId": "lane-system", "title": "Did anyone refuse?" }
],
"edges": [
{ "source": "node-decide", "target": "node-approved", "condition": "!getVariable(\"refused\")", "label": "nobody did" },
{ "source": "node-decide", "target": "node-refused", "condition": "getVariable(\"refused\")", "label": "somebody did" }
]
And the process's On start seeds the variable before either route can touch it:
updateRecord("par_purchaseorder", getRecordRef("record"), { "state": 0, "reason": 270160001 });
setVariable("refused", false);
That second line matters more than it looks. Without it, a run where nobody refused would reach the branch with refused
never set, and the branch would be asking about something that doesn't exist yet. Every variable a branch reads should be given
a value at the start.
What routes share, and what they don't
Two kinds of thing travel through a run, and they behave differently across a fork:
| Variables | Record references | |
|---|---|---|
| Set with | setVariable("refused", true) |
addRecordRef(...), setRecordRef(...) |
| Shared by every route | Yes: one route sets it, the others see it | No: each route keeps its own |
| After the join | The same values | The routes' lists put together |
| Good for | Did anyone refuse? | Who answered? |
The sample uses both. refused is a variable, because any route may need to say no to the whole process. And each sign-off
adds who decided it to its own route's references; after the join those lists are put together, and the branch reads them
into a variable for the record:
setVariable("answered_by", getRecordRefs("answered"));
Process variables covers variables in full.
Three ways to join
| Carries on when | Means | Example |
|---|---|---|
| Every route has arrived | Everybody must answer | Finance and Legal sign off |
| The first route arrives | Anybody may answer for all | Either of two managers approves |
| A number of routes have arrived | Enough of them | Two of three directors |
The last two stop the routes still going when the join carries on, and take their tasks out of people's lists, so nobody is left looking at a task for a decision that has already been made. Use them only when the remaining answers really don't matter: with The first route arrives, a manager who would have said no never gets to.
Designing parallel work
- Only split what is truly independent. Finance and Legal each judge the order on their own terms, so neither needs the other's answer first. If Legal needs to see Finance's figures, they are in sequence, not in parallel.
- Give each route its own fields. Finance writes a finance note, Legal a legal note. Two routes writing the same field would have the last one win, and the first one's words lost.
- Bring every way out back to the join. A route that takes a different way, as Finance refused does, still reaches the join, so the join counts it as answered.
- Decide after the join. The branch that reads
refusedsits after both routes, where both answers are in.
Questions that come up
Can a fork have more than two ways out? Yes. Each way out is a route, and a join can wait for all of them, the first, or a number of them.
Can a route have several steps? Yes. A route is everything from the fork's connection to the join: Legal's route could be a review and then a signature, while Finance's is one step.
Can a fork sit inside a route of another fork? It can, as long as every fork has its join. The problems panel's Forks: N. Joins: N. is the check that the splitting and the merging match.
A note on finishing early
The shapes article showed a Finish's When a route reaches it. This is where it matters. By default, a route reaching a Finish ends only that route, and the run ends when no other route is still going. Choose End the whole run and reaching it stops every other route as well: the way to say "refused, don't bother asking Legal".
This article stays in the designer. Running this process, and watching both tasks arrive at once, comes in the next series.
Try it
Set Both have answered to The first route arrives. Now whoever answers first decides whether the order is approved, and the other person's task is taken out of their list. Then set it back to Every route has arrived, or close without saving.
Next: connecting and arranging: drag to connect, and connections that route around shapes.