# Data steps

> Data steps read and write records through a view. Read with filters, create and update records, bulk import, and group writes in a transaction.

Data steps read and write records. Every read and write goes through a view you pick on the step, never straight to the table. That view's filter, hidden columns, and read-only columns apply, just as they do for people. So pick a view that shows exactly the records the process should work with.

## Read records

**Read DataView** reads records from a view. You can add a filter and a limit. It returns the matching records and the total count. Connect its output to **For Each** to handle the records one by one.

To build a filter from values earlier in the run, such as the customer on this order or the status someone chose:

- **Make Filter** builds one condition from a column, an operator, and a value.
- **Make Filter Group** combines conditions with AND or OR. Connect the group to **Read DataView**.

If the filter never changes, set it on the step directly.

## Use the fields of a record

**Break Entry** splits a record into its fields, one output per column, so later steps can use the customer, the status, or the total.

## Write records

| Step | What it does |
| --- | --- |
| **Write DataView** | Creates, updates, upserts, or deletes one record through a view. An upsert updates the record that matches on a column you pick, such as an order number, or creates it if there's no match. Returns the record. |
| **Make Payload** | Builds the values for a write, with one input per column. |
| **Update Entry Field** | Sets one field on an existing record. |
| **Archive Entry** | Archives a record. |
| **Restore Entry** | Brings back an archived record. |

Writes from these steps run the table's [business rules](/docs/business-rules), just like a save by a person. If a validation or guard refuses the write, the step fails. Use **Try / Catch / Finally** if the workflow should handle that.

## Import many records at once

**Bulk Upsert DataView** writes many records in one step, matched on a column you pick, such as an article number. Use it for a large import or a regular sync. **Map Array to Payloads** turns a list of items into records ready for a bulk upsert, without a loop.

> **Warning:** **Bulk Upsert DataView** skips business rules to stay fast. Validations, guards, computations, and side effects don't run for these records. If the rules must run, use **Write DataView** inside a **For Each** loop instead, or check the data in the workflow before the write.

## Group writes in a transaction

When several writes must all succeed or all fail, such as an order and its lines, or moving stock from one location to another, put them in one ACID-compliant database transaction with **Begin Transaction**.

1. Add **Begin Transaction**.
2. Put the reads and writes on its **Body** path, and connect each one's transaction input to the **Begin Transaction** step.
3. End the body by connecting back to **Commit** to keep the changes, or to **Rollback** to undo them all.
4. Continue the workflow from **After**.

If anything inside the body fails, none of the writes are kept.

> **Note:** Inside a transaction, use only data steps, values, branches, and logging. Keep waits, emails, HTTP requests, and approvals outside the transaction, after the commit. That way an email never goes out for an order that was rolled back.

## Plan your data steps

For each read, name the view and the filter. For each write, name the view, the operation, and the fields. List writes that must agree and put them in one transaction. If you use a bulk upsert, note that business rules don't run, and add the needed checks before it.

  - [Business rules](/docs/business-rules): What runs when a workflow writes a record.
  - [Base views](/docs/base-views): Control which records a view, and so a workflow, can reach.
  - [Flow steps](/docs/workflows/nodes/flow): Loops, branches, and error handling.

---

Source: https://community.sapugo.app/docs/workflows/nodes/data
