Skip to content
Guides

Reuse steps with components

Save steps you build again and again as a component, drop it into other workflows at a pinned release, test it on its own page, and release changes when you choose.

On this page
Reuse steps with components. Save the three steps that turn an SIU appointment into a warehouse row as a component, use it in a second workflow pinned to release 1.0.0, see where it is used, and release a change as 1.1.0 that each workflow picks up when you choose.

Many workflows repeat the same few steps: parse the message, map it, post the row. Save those steps once as a component and use it in every workflow that needs it. Each workflow pins a release of the component, so a change reaches a workflow only when you pick the new release there.

You will turn three steps of a scheduling workflow into "SIU to appointment row", drop it into a second workflow, test it, and release a change.

flowchart LR
    A[Demo Health SIU] --> C[SIU to appointment row 1.0.0]
    B[Demo Health clinic B] --> C
    C --> D[Parse]
    D --> E[Map]
    E --> F[Shape the row]

1. Save the steps as a component

  1. Open the workflow and select the Source step (or a destination).
  2. On the Source transformer header, choose Save as component. Its steps start picked; untick any you want to keep out. Picked steps must follow on from each other and end in one step.
  3. Name it ("SIU to appointment row") and say what it does in a sentence.
  4. Check What it needs and gives back. It is filled in from the steps' data maps: a component that reads the HL7 message takes it as it is, and the last data map's fields are its outputs. Add or change fields as you need.
  5. Keep Use the component here, in place of these steps ticked and choose Save component.
  6. Save the workflow.

The component is released as 1.0.0 straight away, and the three steps are now one Component step that pins it. A step with a password or token typed into it can't be saved: a component is shared, so move the value into a connection or a workspace secret ({{env.NAME}}) first.

In the Graph view, the same dialog opens from the test panel (Save steps as component), and you can pick any connected steps.

2. Use it in another workflow

  1. Open the second workflow and select Source (or a destination).
  2. Choose + Use a component, then pick the component. Its newest release is pinned, and the step shows what it expects and returns.
  3. Save, then deploy as usual.

In the Graph view, Component is in the step palette.

When a message runs, the component's steps run inside that workflow's run. The run's Steps tab shows each of them as "SIU to appointment row › Map", between a check of its inputs and the Component step itself, whose output is the component's outputs.

3. Test it on its own page

Open Workflows, then ··· › Components, then the component. Under Tests, choose Add a test: paste a synthetic sample (for example an SIU^S12 for TESTPATIENT), run it through the component's steps, and Save as test case. Run tests runs every saved test on the draft. Each release runs them first.

4. Change it and release

  1. On the component's page, choose Edit steps and change a step in the designer, or change What it needs and gives back and Save to draft. Both save a draft: the workflows that use the component still run 1.0.0.
  2. Choose Publish release…. The next label is suggested (1.1.0); say what changed. The tests run first, and a failing test holds the release back.
  3. Used by lists each workflow and the release it runs, and marks the ones with Update available. You can open a workflow and pick the new release on its Component step, or update them all from the impact (next).

5. See the impact, test and update

After a release, Impact of 1.1.0 on the component's page lists every workflow that uses it and the release each one pins.

  1. Read what changed in what it needs and gives back. A removed output, a changed type or a new required input is Breaking · major.
  2. Choose Run tests. Each workflow's saved test cases run against 1.1.0 without sending anything. A workflow whose test fails is marked Held back: its tests failed, with the case and the fields that differ.
  3. Choose Update all (or tick some workflows and Update selected). Each one that passes gets a new draft pinned to 1.1.0; the others stay as they are, with the reason. For a major release, or when a row says Major from … (a workflow several releases behind that crosses a major), tick the acknowledgement first. Run tests works before it.
  4. Deploy each updated draft from its Versions tab when you are ready (Deploy it next to it). Until then, production runs the release it ran before.

Every update is audited as component.update, with the workflows updated and held back.

5. One component, every customer's connection

When the component posts somewhere (its last step sends), the workflow decides which connection each customer's messages use; the component keeps only its own default.

  1. In the workflow's Steps view, open the destination that uses the component. Under its Component step, choose Different connection per sender.
  2. + Add sender: DH-NORTH with North API, then DH-SOUTH with South API. Senders not listed use the component's own connection, or choose to fail them.
  3. Save and deploy. A message from DH-NORTH goes through North API, one from DH-SOUTH through South API; the run's step inside the component says which.

6. Promote it to staging

On the workflow's Versions tab, open ···, choose Promote to another workspace and pick Staging. The component goes with the workflow (Goes with it: Component · release 1.0.0 · Created there), its connection is mapped to Staging's own, and the workflow's Component step points at Staging's copy. The component lands there as a draft: open it in Staging, choose Publish release… (it suggests 1.0.0, the release the workflow pins), then deploy the workflow there. A changed component can also be promoted on its own from its page.

7. Make a template from the workflow

When each new customer needs the same workflow with a few values changed, make it a template once and fill in one form per customer.

  1. Open the scheduling workflow and choose Templates › Save as template in the header. Name it "Customer appointments feed". Its page opens.
  2. Under Parameters, + Add a parameter: customer (text, required, "Shown in each row"). Save to draft.
  3. Edit steps: where the customer's name goes, write {{params.customer}}. In a JavaScript step it becomes a quoted value, so write customer: {{params.customer}}.
  4. Publish release… 1.0.0. Built from lists "SIU to appointment row · release 1.0.0".
  5. New from template: name the workflow "Appointments for Demo Health North", fill in customer, pick its connection, Create workflow. Make another for Demo Health South.

Both workflows are listed under Workflows made from it with their values. When you release 1.1.0 of the component, both show Update available ("SIU to appointment row 1.0.0 → 1.1.0"). Update all (2) runs each one's tests first and gives each a new draft, keeping its own customer. A new template release reaches them the same way. See Templates made of components and the recipe New customer feed in one form.

What to know

  • A Component step always runs a release, never a draft.
  • The component runs inside the calling run: same sender, same retries, same order. Nothing extra is queued.
  • Only the declared outputs leave the component, so workflows can't come to depend on its internals.
  • A component that workflows or other components use can't be deleted, and a component can't contain itself.
  • A pick can't end in a filter, condition, parallel or loop step: add the step after it, or stop before it.
  • Secrets are checked on every save and release, not only the first: header values, credentials in URLs and secrets typed into JavaScript included.
  • Opened from its page, the designer marks it Component and leaves out Run now, On and Deploy; Back to component returns to its page.

Reference