Skip to content
MyAppBuilder
StableWorkflow node

Database

Overview

Creates, updates, deletes or finds records of one of your entities.

Purpose

The workhorse of automations: create a job when a quote is approved, update a customer's last-contact date after an email, archive a record, or find a list of records to process in a loop.

Inputs

  • Operation — Create record, Update record, Delete record or Find records.
  • Entity — the entity to work on.
  • Which record (id) (update / delete) — leave empty to use the record that triggered the workflow, or give an id ({{results.job.id}}, {{event.item.id}}).
  • Field values (create / update) — one value per field: static, dynamic or a template such as {{record.customer_email}}. System fields are filled automatically.
  • Only records where (find) — filters (field · operator · value), all of which must match. Values can be dynamic ({{event.email}}, {{results.coupon.0.id}}, {{record.id}}). A value that resolves empty is compared as empty — never skipped — so an empty input finds only records whose field is empty, not every record. Filter on ID to fetch one record.
  • Sort by (find) — a field and a direction; default: oldest first.
  • Max records (find) — 1 to 1000, default 100.
  • Save result as — a key (letters, digits, underscores) under which later steps find the result: Action results › key in the Data Picker or {{results.key}} in templates. Offered for Create record (the created record) and Find records (the list).

Configuration

  • Create and update also start other workflows that wait for that entity (record created / record updated), up to 3 levels deep — avoid loops where a workflow updates the record that triggers it without a field or condition filter.
  • Find records + If / else is how a workflow checks other records: count registrations against an event's capacity ({{results.registered_count}} ≥ {{results.event.0.capacity}}), detect a duplicate vote, or look up a coupon by its code.

Outputs

  • Create: results.<key> = the new record; step output { id }. Reference it as {{results.job.id}} or Action results › job.
  • Update / Delete: step output { id }.
  • Find records: results.<key> = the matching records (sorted, at most Max records — feed it to Repeat for each, or read the first one with {{results.<key>.0.field_key}}), and results.<key>_count = how many records match in total (before the limit). Step output { count }.
  • Find records with a total of field (beta, plan / config level): also results.<key>_sum, results.<key>_min and results.<key>_max of that numeric field over every match (not just the limited records) — exact decimals, 6 decimal places; _sum is 0 and _min / _max are empty when nothing matches.
  • Find records with a date range (beta, plan / config level): keeps only records whose [start field, end field) range overlaps the requested [from, to) range — half-open, so back-to-back bookings don't clash; dates without a timezone are read as UTC; a record without an end blocks everything after its start. A missing range or an end before its start fails the step.

Example

Create a job from an approved quote

Example
Database
  Operation: Create record · Entity: Jobs
  Field values:
    Customer = {{record.customer}}
    Title    = Job for quote {{record.number}}
    Status   = scheduled
  Save result as: job

Next step template: “Job {{results.job.id}} created”

Errors

  • “Entity no longer exists” — the entity was deleted; pick another.
  • Validation errors such as “Title is required” or “Email must be unique” come from the entity's field rules.
  • “Record not found.” — the id for update/delete is empty or does not exist.

Limitations

  • Workflow writes bypass role permissions (they run as the system), so be deliberate about which triggers can reach them.
  • Find records returns at most 1000 records per step (the _count, _sum, _min and _max are computed over every match, up to 20,000 records).
  • Runs started by a button, form or test run hold the project's data lock: a Find records check and the writes after it are atomic (concurrent runs wait), and a step error rolls back the run's writes. Workflows started by record changes are not locked as a whole — each write is.
  • When a step fails, the run stops there, is marked failed in Run history with the step name and error, and the remaining steps are skipped.

Advanced

  • Config: { operation: "create" | "update" | "delete" | "query", entityId, values?, recordId?, filters?: Filter[], sort?: { fieldId, direction }, limit?, resultKey? }. Values may be Bindings, template strings or plain values (bindingOf). Filter fieldId is a field id, field key or id.
  • Create/update/delete call the data engine with { system: true }; query resolves filters with resolveStrictFilters (empty values are not skipped), uses listRecords with an owner-level system user, slices to limit and stores results[key] and results[key + "_count"]; the public sandbox preview runs the same logic in the browser (findRecords). Nested record triggers are fired with depth + 1 after the run commits (afterCommit).
  • Rule primitives (beta): aggregate?: fieldId — exact decimal sum / min / max (scaled integers, 6 places); overlaps?: { startFieldId, endFieldId, start: Binding, end: Binding } — half-open range overlap (recordOverlaps). The query logic is findStep() in src/core/bindings/rules.ts, shared by the server and the sandbox. Both options are validated by createworkflow / updateworkflow / addworkflownode (workflowRuleIssues). Plan syntax: find_records with aggregate: "Quantity" and overlaps: { start, end, from, to }.

Related

Was this helpful?