Skip to content

Tutorials

Tutorial: build an approval workflow

Build an expense approval: a form trigger, a User Task assigned to the manager with outcomes, a condition, Set Variable with several variables, an email, a parallel step with a Done edge, Save & test, the process view and run history.

Last updated 5 min read Edit this page on GitHub
On this page

Goal: when someone submits an Expense claim form, their manager approves or rejects it. Large approved claims also notify finance. The requester gets an email either way.

You need: Create workflows and Edit workflows, plus Edit forms for the form. Owner, Admin and Manager have them.

Time: about 30 minutes.

1. Make the form#

Build a form called Expense claim with these fields. The first form tutorial shows how.

LabelKeyType
TitletitleText, required
AmountamountCurrency, required
ReceiptreceiptAttachments

2. Create the workflow#

  1. Go to Build › Workflows and select New workflow.
  2. Enter the Name Expense approval. For Trigger, choose When a form is submitted.
  3. Select Create workflow. The builder opens with a Form Submitted trigger.
  4. Select the trigger. In Form, choose Expense claim. The Available downstream box lists what the next steps can use, such as {{form.amount}}, {{submitted_by_name}}, {{submitted_by_email}} and {{submitted_by_manager_id}}.
The workflow builder with the node palette folded to its rail, the canvas and the Configure panel
The builder: the Nodes palette on the left (folded to its rail here), the canvas, and Configure / Data / Variables on the right.

3. Work out the approver (Set Variable)#

Drag Set Variable from the palette and connect the trigger to it. Add two rows. Rows run top to bottom, so a later row can use an earlier one.

VariableExpression
approver_id{{=COALESCE(submitted_by_manager_id, "<your user id>")}}
is_large{{=form.amount > 1000}}

submitted_by_manager_id comes from the reporting lines in Org. COALESCE falls back to you when the requester has no manager.

Set Variable configJSON
{
  "assignments": [
    { "name": "approver_id", "expression": "{{=COALESCE(submitted_by_manager_id, \"<your-user-id>\")}}" },
    { "name": "is_large", "expression": "{{=form.amount > 1000}}" }
  ]
}

4. Ask the manager (User Task)#

Add a User Task after Set Variable and fill in Configure:

  1. Task title: Approve {{form.title}} from {{submitted_by_name}}.
  2. Instructions: Amount: {{form.amount}}.
  3. Assignment: choose Individual, then under Or use a variable: enter {{approver_id}}.
  4. Due date: Relative, 3 days after creation. Under Reminders, select Add reminder.
  5. Outcomes: Approve and Reject. Each outcome adds a port on the canvas.
  6. Form (optional): add a Long text field with the key review_note for the manager's comment.

Other ways to assign a task:

  • Individual: a named person. Pick them, or use a variable.
  • Team: anyone in the team can pick it up.
  • AAD Group: an Entra ID group. It appears when your workspace has an enabled Entra ID directory connection (Settings → Directory sync). Choose Anyone in the group can claim it or Everyone in the group gets it.
  • The person's manager: as above, {{submitted_by_manager_id}} in a variable.

There is no assignment by role. Use a team for a group of people. See Assignment and SLAs.

User Task configJSON
{
  "task_title": "Approve {{form.title}} from {{submitted_by_name}}",
  "task_description": "<p>Amount: {{form.amount}}</p>",
  "task_priority": "medium",
  "assignment_type": "individual",
  "assignee_variable": "{{approver_id}}",
  "outcomes": ["Approve", "Reject"],
  "due_date_mode": "relative",
  "due_offset_amount": 3,
  "due_offset_unit": "days",
  "reminders": [{ "offset_minutes": 1440 }],
  "fields": [{ "key": "review_note", "label": "Comment", "type": "textarea" }]
}

When the task is done, the next steps can read {{outcome}}, {{actioned_by_name}} and each field as {{task_data.review_note}}.

5. Branch on the outcome and the amount#

Drag from the task's Approve port to a new Branch by Condition step. The edge gets the label Approve. In the condition:

  1. Name the first branch Large. Add rule: {{is_large}} is_true.
  2. Tick Include Else branch (catches everything else).

All branches are checked, and every branch that matches runs. Add an Else branch to catch the rest.

Branch by Condition configJSON
{
  "branches": [
    { "label": "Large", "logic": "and", "rules": [{ "field": "{{is_large}}", "operator": "is_true", "value": "" }] }
  ],
  "has_else": true
}

For a choice between fixed rules (amount bands, departments, regions), use a decision table instead.

6. Notify finance and the requester at the same time (Parallel)#

From the Large port, add a Parallel / Sequential step. Keep All at once and name the branches Finance and Requester.

  1. From the Finance port, add Send Email. To: your finance address. Subject: Large expense approved: {{form.title}}.
  2. From the Requester port, add Send Email. To: {{submitted_by_email}}. Subject: Approved: {{form.title}}. Body (HTML): <p>Approved by {{actioned_by_name}}. {{task_data.review_note}}</p>.
  3. From the Done port of the Parallel step, add End Workflow with the Reason Approved (large).

The Done edge runs once, after every branch has finished. Use it for whatever must happen after all the parallel work, not on one branch.

Parallel configJSON
{ "mode": "parallel", "branches": [{ "label": "Finance", "order": 1 }, { "label": "Requester", "order": 2 }] }
Send Email config (Requester branch)JSON
{ "to": "{{submitted_by_email}}", "subject": "Approved: {{form.title}}", "body": "<p>Approved by {{actioned_by_name}}. {{task_data.review_note}}</p>" }

7. Finish the other paths#

  • From the condition's Else port: Send Email to {{submitted_by_email}} with Approved: {{form.title}}.
  • From the task's Reject port: Send Email to {{submitted_by_email}}, subject Rejected: {{form.title}}, body {{task_data.review_note}}.

A path with no outgoing edge simply ends. End Workflow is optional, but it records a reason.

8. Save & test#

  1. Select Save & test. The Test workflow panel opens.
  2. Select Add test case, fill in the form (an amount of 1500), then Run selected.
  3. The Process view shows each step as it runs. At the User Task the status is Awaiting action, with one button per outcome. Select Approve.
  4. Check that both emails ran and the Done edge ran after them. Logs lists every step with its inputs and outputs.
  5. Add a second case with an amount of 200 and check that it takes the Else path.
The Test workflow panel with the process view paused at a user task
Save & test: run test cases and act on tasks from the panel.

9. When a test fails#

If a step fails, the test shows the error on that step. When the Agent is on and you can edit the workflow, select Ask Agent to fix next to the error.

  1. The Agent explains the cause in plain words, for example "{{form.amout}} doesn't exist: the field's key is amount."
  2. Where it can, it proposes a fix on a confirmation card. Read it and select Confirm.
  3. Select Re-run test under the change to run the same test case again.

Some failures have no safe fix in the workflow, such as an email service that is down or a missing permission. The Agent then says why and what to try next. Failed real runs have the same button on their Process view; there the Agent only proposes draft fixes and never retries the run. See Ask Agent to fix.

10. Publish and watch the runs#

  1. Select Publish, add Publish notes and confirm. Publishing makes this version live and turns the workflow on. Runs already under way stay on their version.
  2. Submit the real form.
  3. In the builder's ⋯ menu, select View runs. Open a run for its Process view, Variables and Logs, and the User Tasks it created.
The process view of a run with completed and waiting steps
The process view of a run.

What you built#

  • A form-triggered workflow that sets two variables and assigns a task to the requester's manager.
  • Outcome branches, a condition with an Else branch, and a parallel step whose Done edge runs after both emails.
  • Test cases you can run again after every change, and a published version with run history.

Next steps#

Was this page helpful?