Parsware
All articles

Process design

Export and import a process

A process design is a plain JSON file you can export, edit and import, and the import checks it before anything reaches the canvas. Export a picture, PNG or SVG, for a document or a slide. Trying both, we fixed two things: the pictures now carry the lane names, and a refused file names the missing node.

The Parallel Sign-Off process on the canvas after importing a file that renamed the Finance lane to Treasury, next to the title "Export and import a process"

Underneath the drawing, a process is a plain text document: lanes, steps, connections, coforms and scripts, in JSON. You never have to look at it. But it means you can export a process as a file, import one back, and export a picture of it for somebody who will never open the designer.

We used the Parallel Sign-Off sample from samples/solutions/bpms-parallel-sign-off.

Where the buttons are

Import JSON and Export JSON are in the title bar, beside Save and Publish. The pictures are under the designer's own Export menu:

The process designer page for Parallel Sign-Off: Publish, Save, Start a run, Import JSON, Export JSON and Close in the title bar, and the designer with its Export, Edit, View and AI menus below

Export JSON

Export JSON downloads par_parallelsignoff.bpms.json. It's what is on the canvas now, including edits you haven't saved, because the point of the file is to carry this design somewhere else. The start of ours:

{
  "$schema": "bpms-design/v1",
  "version": 1,
  "meta": {
    "id": "par-parallel-sign-off",
    "name": "Parallel Sign-Off",
    "title": "Parallel Sign-Off",
    "description": "Finance and Legal decide at the same time; a join waits for both.",
    "scripts": {
      "onStart": "updateRecord(\"par_purchaseorder\", getRecordRef(\"record\"), { \"state\": 0, \"reason\": 270160001 });\nsetVariable(\"refused\", false);"
    }
  },
  "variables": [ … ],
  "forms": [ … ],
  "lanes": [ … ],
  "nodes": [ … ],
  "edges": [ … ]
}

Everything you set in the designer is in there, coforms and scripts included. It's readable, it diffs well in source control, and it's the same format the designer's AI button asks a model to write.

Export a picture

Export → Image (PNG) or Image (SVG) draws the whole diagram as it looks, not just the part in view:

The Export menu open in the designer, offering Image (PNG) and Image (SVG)

This is the PNG it gave us:

The exported picture of Parallel Sign-Off: four bands named Buyer, Finance, Legal and System, with the order raised, the fork, the two sign-offs, the refusals, the join, the branch and Done

The lane names are new. On screen they sit in a column laid over the canvas, so they stay put while you scroll. The export drew only the canvas, so the picture showed every step and not who does them, which is the whole point of drawing a process on lanes. Each lane's name is now drawn into the picture. We fixed it while writing this.

SVG is the one to use in a document that will be printed or zoomed. Neither picture is the process: you can't import one back.

Import a file that's wrong

Import JSON opens a file picker. The file is checked before it goes anywhere near the canvas: the version, the lanes, the nodes, and that every connection joins two steps that exist.

To see that, we edited the exported file by hand and pointed the connection out of the join at a step called node-decision, which doesn't exist. Importing it was refused:

A red message above the designer: That file is not a valid process design: Edge edge-both-decide connects to a node that is not in the design (target node-decision)

The canvas didn't change. The message names the connection and the missing step, so you know what to search the file for. It used to say only that the connection "references unknown node(s)", which left you to check both ends against every step by eye. That changed while we wrote this, too.

Import a file that's right

Then we renamed the Finance lane to Treasury in the file and imported that:

The designer after the import: the second lane now reads Treasury in the outline and on the canvas, and a message at the top says Design loaded. It is not saved until you select Save.

The red message from the refused file goes when this one loads. It used to stay up beside the new one, as if this file had been refused too; we fixed that while making the video.

An import replaces what's drawn and doesn't save. If it turns out to be the wrong file, leave the page without saving and nothing has changed. If it's right, look it over and select Save.

Files, or the solution?

A process travels in its solution: export the solution, import it into Test or Production, and the process goes with its coforms and its roles. That's how work should move between environments.

Export and import JSON are the hand tools: copying a design to try something, keeping one in source control, editing many steps at once in a text editor, or bringing in a design somebody wrote or generated elsewhere. Either way, the same check runs.

A map of the file

The six top-level parts of a .bpms.json file, and where each is covered in this series:

Part Holds Read more
meta The name, description and the process's own scripts: onStart, onComplete, onCancel Code on a task
variables What the run carries from step to step Process variables
forms The coforms, with their fields and outcomes Coforms
lanes The swimlanes, and a role or rule list for each Swimlanes and roles
nodes Every step, with its kind, type, lane, assignment and scripts The shapes
edges Every connection, with its condition or outcome Branch conditions

The positions of the boxes, x, y, width and height, are in the nodes as well. They matter only to the drawing, so a file written by hand can leave them rough and let View → Auto arrange tidy it after the import.

Editing many steps at once

The file earns its keep when a change touches many steps. Two examples:

  • A role renamed. A solution replaces par_manager with par_line_manager. In the file, one search and replace fixes every role("par_manager") and every lane role, where the designer would mean clicking each step.
  • A status renumbered. Several script steps write "reason": 270160003. Changing them all is one edit in a text editor.

After editing, import the file, look at the problems panel, and save. The check on import catches a broken connection; the panel catches the rest, such as a variable a script names that the edit removed.

Things worth knowing about ids

Every lane, node, edge and variable has an id, and the connections refer to steps by it: "source": "node-split". Keep ids stable when you edit by hand:

  • Change titles freely, they're for people. Changing an id means changing every edge that refers to it, or the import refuses the file, as the example above showed.
  • Give new things new ids. Two steps with the same id can't be told apart, and the import says so.
  • Copy a step by copying its node and giving it a new id, then add the edges that connect it.

Writing a process with the assistant

The designer's AI button asks a model to write exactly this format. Because the result goes through the same check as an import, a generated design that refers to a missing step, or a lane that doesn't exist, is refused with the same message a hand-written file would get. A good result still needs reading, though: the assistant can draw a well-formed process that sends work to the wrong role. Treat it like a first draft from a colleague, and review it in the designer before saving.

Questions that come up

Can I import a BPMN file from another tool? No. The importer reads this platform's process format, bpms-design/v1. A process from another tool is redrawn, or rewritten into this format.

Does importing a file publish it? No, and it doesn't even save it. An import replaces what's on the canvas; Save keeps it, and Publish makes it the version that runs.

Is an exported file safe to share? It holds the process's design: its steps, scripts and coforms. It holds no records and no environment's values, so it carries nothing private beyond what the scripts themselves say.

Try it

Export the sample, open the file, and change a step's title. Import it, and the step on the canvas has its new name. Then delete a lane from the file, leaving its steps, and import again. The message names the step whose lane is missing.

Next: processes that actually run, from drawing to a person's task list.