Parsware
All articles

Process design

The shapes: start, task, branch, finish

Four shapes carry most processes: a start, tasks, a branch where the process decides, and a finish. We opened the two-step approval sample and clicked each one to see what it asks for and where it can connect, and found the designer letting a connection leave a Finish without a word. It says so now.

The Two-Step Change Approval process in the process designer: Record created, Review and correct, Approve the change, Mark approved, Mark rejected and Done across four lanes, next to the title "The shapes: start, task, branch, finish"

The palette offers seven shapes. Four of them carry most processes: a Start, Tasks, a Branch where the process decides, and a Finish. This article clicks each one and looks at what it asks for and where it can connect. Fork, Join and Timer get their own articles.

We used the Two-Step Record Approval sample. Import it from samples/solutions/bpms-two-step-record-approval to follow along, then open its process, Two-Step Change Approval.

The process

The Two-Step Change Approval process: Record created in the Requester lane, Review and correct in First manager, Approve the change in Second manager, then Mark approved or Mark rejected in System, both ending at Done

A change request is raised. The first manager may correct it. The second manager approves or rejects it. A script step writes the answer back onto the record, and the run ends.

Start: where a run begins

Click Record created:

Record created selected: its properties are a title, a name, a description and its colours, and nothing else

A start has a title, a name and its looks. There is no code on it, because nothing happens at a start: a run is created there and moves straight on. Code that should run when the process begins goes on the process itself, under On start. Select the root in the outline to find it.

  • One per process. A second start is a problem the designer reports on the extra one.
  • Only ways out. Nothing leads into a start.

Task: a step

Click Review and correct:

Review and correct selected: Type is User, then who may not decide it, its coform, what the person looks at, a deadline, and its code

A task is a step, and its Type says what kind. This one is a User task: a person does it. So it asks who (Assigned to, in its code), which short form they fill in (the Coform), what they look at while they decide, and when it's due.

Now click Mark approved:

Mark approved selected: Type is Script, and under Code only On enter and On exit

A Script task is work the platform does by itself. Nobody is given it, so there's no coform and no assignment, and its code has only On enter and On exit. The next article goes through every type.

A task has one way out. The exception is a user task whose coform offers several buttons: Approve the change has Approve and Reject, and each has its own connection. That's how this sample decides without a branch.

Branch: where the process decides

This sample has no branch, so we dropped one onto the canvas to look at it:

A new Branch diamond in the Second manager lane, and the problems panel: Branch cannot be reached from the Start, and Branch is a Branch with fewer than two ways out

A branch is a decision: one way in, two or more ways out, and a condition on each way out. The run takes the first connection whose condition is true. The problems panel already had two things to say about ours: nothing leads to it, and a decision with one answer is not a decision.

Use a branch when the process decides from its data, such as an amount over a limit. Use a coform's buttons when a person decides. Conditions are the subject of a later article.

Finish: where a route ends

Click Done:

Done selected, with the When a route reaches it choice open: End this route, the run ends when no other route is still going; or End the whole run, and stop every other route

A process can have several finishes: approved and rejected are both endings. A finish has one choice, When a route reaches it:

  • End this route (the default). The run ends when no other route is still going.
  • End the whole run, and stop every other route. For "rejected, stop everything".

The difference only matters once a process runs on two routes at once, after a Fork. We come back to it in the fork and join article.

This choice is new. The engine has supported it for a while, but the designer never showed it, so every finish ended only its own route. We added it while writing this.

The shapes, as the process stores them

Each shape is a node in the process document, and each connection an edge. The sample's, with positions left out:

"nodes": [
  { "id": "node-start", "kind": "start", "laneId": "lane-requester", "title": "Record created" },
  { "id": "node-second-approval", "kind": "task", "taskType": "user", "laneId": "lane-second",
    "title": "Approve the change", "assignment": "role(\"par_change_approver\")", "form": "par_second_approval" },
  { "id": "node-mark-approved", "kind": "task", "taskType": "script", "laneId": "lane-system", "title": "Mark approved",
    "scripts": { "onEnter": "updateRecord(\"par_changerequest\", getRecordRef(\"record\"), { \"state\": 270150000, \"reason\": 270150002 });" } },
  { "id": "node-finish", "kind": "finish", "laneId": "lane-system", "title": "Done" }
],
"edges": [
  { "source": "node-second-approval", "target": "node-mark-approved", "label": "Approved", "outcome": "approved" },
  { "source": "node-second-approval", "target": "node-mark-rejected", "label": "Rejected", "outcome": "rejected" },
  { "source": "node-mark-approved", "target": "node-finish" }
]

Two things in it explain how this process decides without a branch:

  • Approve the change names a coform, par_second_approval, whose buttons are Approve and Reject.
  • Each of its two edges carries an outcome, approved or rejected, matching a button. Pressing a button follows the edge with that outcome.

A branch's edges carry a condition instead, an expression such as getVariable("approved"). One way to decide is a person pressing a button; the other is the process reading its data.

What happens at the start, then

A start has no code of its own, but the process does, under On start, and it runs as the run begins. This sample uses it to mark the change request as in review the moment a run starts:

updateRecord("par_changerequest", getRecordRef("record"), { "state": 0, "reason": 270150001 });

getRecordRef("record") is the record the run is about, the change request that started it. Setting its state and reason here means the record says in review for as long as the run is going, and the script tasks at the end move it to approved or rejected. States and reasons explains the numbers. The process's On start is also where to give its variables a starting value, as the leave sample does with setVariable("approved", false), so a branch never reads a variable nothing has set.

Buttons or a branch?

The decision Use Because
A person approves or rejects Coform buttons, one edge per outcome The person's choice is the decision
The amount decides who approves A branch, conditions on its edges The data decides, with nobody to ask
A person decides, and the amount decides what happens next Both: buttons, then a branch Two decisions, made by two different things

Buttons keep the drawing short and make it obvious what a person may choose. A branch is right whenever the answer is already in the data. Coforms: a form for a task builds the buttons, and Branch conditions writes the conditions.

Shapes that make a process easy to read

The shapes are few, so a process is mostly readable by default. A few habits keep it so:

  • Name every step with a verb: Review and correct, Mark approved. A step called Manager says who, not what.
  • One finish per outcome, when the outcomes really differ. Approved and Rejected finishes read better than one Done with both arrows arriving, if anything later reports on how runs ended.
  • Script steps in their own lane, System, so the people's lanes show only what people do.
  • Label every way out of a branch and every button's edge, Approved, Over the limit, so the drawing reads aloud.
  • Left to right, in the order it happens, and the problems panel at Nothing wrong with this process before saving.

Questions that come up

Can a process have two starts? No. A second start is reported as a problem. A process that can begin in two ways, by a button or by a record, starts in one place and branches on how it began.

Can a task lead back to an earlier one? Yes, a loop back is allowed, such as Rejected: correct and resubmit. Make sure something about the run changes each time round, or it can circle for ever.

Is the name or the title used by code? The name. It is what scripts and the run history refer to, so keep it short and stable; the title is for people and can change freely.

Where a shape can connect

Choose Connect and drag from one shape to another. To see what happens with a connection that makes no sense, we dragged one from Done back to Mark approved:

A connection drawn from Done to Mark approved, selected, and the problems panel: A connection leaves the Finish "Done". The run ends there, so it never takes it

This used to say "Nothing wrong with this process." The connect tool joins any two shapes, and a connection into a start or out of a finish was accepted without a word, while a run would never take it. We found that trying it for this article and fixed it: both are now problems, reported on the connection so a click selects it for you to delete. The same check runs when a process is published, so one can't slip through.

In short:

Shape Ways in Ways out
Start none one
Task any one, or one per coform button
Branch any two or more, each with a condition
Finish any none

We didn't save any of this. The sample is a managed solution, and closing the designer without saving leaves it as it was.

Try it

Drop a Branch into the System lane and watch the problems panel as you connect it:

  1. Connect Approve the change to it. The branch is now reachable, but it leads nowhere and has fewer than two ways out.
  2. Connect it to Mark approved and to Mark rejected. Both of those go away, and each new connection is reported instead: it leaves a Branch with no condition.

That last message named the connection by its internal id, a long string of letters and digits, until we changed it while writing this. It now names the two steps it joins, Branch → Mark approved, or the connection's label if it has one. Close without saving when you're done.

Next: task types: user, service, script, manual, send, receive and business rule.