How to Build Notion Database With Workflow State Machine via Formula
🔍 WiseChecker

How to Build Notion Database With Workflow State Machine via Formula

A workflow state machine tracks the status of tasks or items through defined stages such as Draft, In Review, Approved, and Published. Without a state machine, manual status updates can lead to inconsistent data and missed transitions. Notion formulas can enforce valid transitions and display the current state clearly. This article explains how to build a database that uses a formula-based state machine to control workflow progression.

Key Takeaways: Building a Notion Workflow State Machine

  • Select property with status options: Defines the current state of each item and serves as the input for the formula.
  • Formula property with ifs and contains: Checks the current state and a transition trigger to output the valid next state or an error message.
  • Rollup or relation property for transitions: Captures the trigger event, such as a checkbox or date field, to advance the state.

ADVERTISEMENT

What Is a Workflow State Machine in Notion

A state machine is a logic structure that defines a set of states and the rules for moving between them. In Notion, you implement this using a combination of property types: a Select property for the current state, a Formula property to calculate the next state, and a trigger property such as a checkbox or date. The formula enforces that only valid transitions occur. For example, a task cannot move from Draft directly to Published without going through In Review and Approved. This prevents data entry errors and keeps workflow consistent across a team.

Prerequisites: You need a Notion database with at least three properties: a Select property named Status, a Formula property named Next State, and a trigger property such as a Checkbox named Approved. The formula uses the if and contains functions to evaluate the current state and the trigger condition.

Steps to Build a Workflow State Machine Using Formulas

  1. Create the Select property for current state
    Add a Select property and name it Status. Add the options for each state in order: Draft, In Review, Approved, Published. Do not add extra states such as Archived yet; keep the list minimal for the initial setup.
  2. Add a trigger property
    Add a Checkbox property named Ready for Next Step. This checkbox will be used as the signal to advance the state. You can also use a Date property named Review Date if you prefer a time-based trigger.
  3. Create the Formula property
    Add a Formula property and name it Next State. Enter the following formula to define the transitions:
    if(prop("Status") == "Draft" and prop("Ready for Next Step"), "In Review", if(prop("Status") == "In Review" and prop("Ready for Next Step"), "Approved", if(prop("Status") == "Approved" and prop("Ready for Next Step"), "Published", prop("Status"))))
    This formula checks the current Status and the Ready for Next Step checkbox. If the checkbox is checked and the transition is valid, it returns the next state. Otherwise, it returns the current state unchanged.
  4. Test the transitions
    Create a new item and set Status to Draft. Check the Ready for Next Step checkbox. The Next State formula should display In Review. Uncheck the checkbox and change Status back to Draft. Check the box again; the formula returns In Review again. This confirms the state machine works.
  5. Automate the state update
    Notion formulas cannot write to other properties automatically. To update the Status property, you must manually copy the value from Next State to Status. Alternatively, use a Notion automation: create an automation that triggers when Ready for Next Step is checked and sets Status to the value of Next State. Go to the database menu, select Automations, and create a new automation with the condition “When Ready for Next Step is checked” and the action “Set Status to Next State”.

ADVERTISEMENT

Common Mistakes and Limitations

Formula returns the wrong state

If the formula returns an unexpected state, check the exact spelling of the Status options. The formula uses case-sensitive string comparison. For example, “Draft” and “draft” are different. Also ensure the trigger property name matches exactly. If you renamed Ready for Next Step to Approve, update the formula accordingly.

State machine does not prevent backward transitions

The formula above only moves forward. To prevent moving backward, add conditions that check if the current state is already higher in the sequence. For example, if Status is Approved, the formula should ignore the checkbox for Draft. The formula in step 3 already does this because each if condition requires the current state to match exactly. If a user manually sets Status to Draft after it was Approved, the formula will still return Draft because the checkbox is unchecked. To block manual edits, use a formula that displays an error: if(prop("Status") == "Draft" and prop("Ready for Next Step"), "In Review", if(prop("Status") == "In Review" and prop("Ready for Next Step"), "Approved", if(prop("Status") == "Approved" and prop("Ready for Next Step"), "Published", "Invalid transition"))). This returns “Invalid transition” for any state that does not match a valid rule.

Automation does not update Status

If the automation fails to update Status, verify that the automation is enabled and that the trigger property is set to the correct database. Also confirm that the Next State formula is not returning an error. If the formula returns “Invalid transition”, the automation will set Status to that string instead of a valid state.

Workflow State Machine: Manual vs Automated Update

Item Manual Update Automated Update
How status changes User copies Next State value to Status property Notion automation sets Status when trigger is checked
Setup complexity No automation needed; only formula and checkbox Requires creating an automation with condition and action
Error risk User may forget to update Status or copy wrong value Automation updates consistently but may fail if formula returns unexpected value
Best for Solo users or small teams with few items Teams with many items needing consistent state transitions

The manual method works for simple workflows with fewer than 50 items. The automated method scales better but requires careful testing of the formula and automation conditions. For most business workflows, start with manual updates and add automation once the state machine is verified.

You can now build a Notion database that enforces a workflow state machine using formulas and a trigger property. Test the formula with a few items before scaling to your full database. For advanced workflows, add more states such as Archived or Rejected by extending the formula with additional if conditions. Use the contains function to check for multiple trigger conditions, for example, both a checkbox and a date being present.

ADVERTISEMENT