Sign Up
Loading...

Save Changes Together

A Database Transaction groups database work so its changes complete together. If a command in the block fails, the block's changes are rolled back.

Example: an order and its stock change

  1. Add Database Transaction to the workflow.

  2. Inside Save changes together, add the supported commands that create the order and change stock.

  3. Add validation for conditions that must hold, such as sufficient stock.

  4. Add any later commands outside the block.

  5. Save and test both a successful order and an order that deliberately fails validation.

After the failed test, verify that neither the new order nor its stock change remains.

The example below places Save Data and Increment or Decrement Field inside the transaction's Save changes together block. Both changes must succeed for the block to finish.

What belongs inside

Use supported database commands inside the block. Keep external database queries, email, SMS, HTTP calls and other external actions outside it. A rollback cannot undo a message already sent or an action performed by another service.

Keep transaction blocks short. Long-running work makes it harder for other requests to use the same records. Nested transaction blocks are not supported.

Availability

Transactions require transaction support in the environment running your workspace. If support is unavailable, the workflow reports an error instead of quietly saving only part of the changes. Ask your administrator if a local or self-hosted environment needs configuration.

Related Topics

CSV Import

Twidget enables seamless import of data from a CSV file into your database. Follow the steps below to successfully import a CSV file. Step-by-Step Guide. 1. Initiate the Import: - Click on the Import button within the table toolbar. - Select Import from CSV from the dropdown. 2. Open Import Dialog: ...

Filter Data

In Twidget, you can easily filter and sort data within the database tables view. This allows you to refine and manipulate the data as needed. Below are the steps and options available for filtering and sorting data. Filtering Data. To filter data: 1. Click on the Filter Button: In the table toolbar,...

Table Relationships

In Twidget, you can connect database table data using the `_id` field that is automatically generated for every row in a table. This `_id` field is essential for creating and maintaining relationships across different tables. Types of Relationships. A one-to-one relationship occurs when a single row...

Database Change Triggers

Run an event automatically when a record is created, updated or deleted in a Twidget table. For example, send a welcome message after adding a customer, or refresh a summary when an order changes. Prepare the event. Create an event containing the steps you want to run. Add an Object input named `tri...

Generate CRUD Endpoints

With Twidget, you can efficiently generate CRUD (Create, Read, Update, Delete) endpoints for your database tables upon their creation. This functionality is designed to streamline the development process and ensure that essential API operations are readily available. Enabling CRUD Endpoints. 1. Crea...