# Update Row

The Update Row action step allows you to update a row or multiple rows in a table by a given condition.

To run this action, you need to specify the *filter condition* to find the row to update, for example:

```javascript
// id = 23
{{ui.table.updatedRow.data.id}}
```

And you also need to specify the *values to update*. You can do this in the following ways:

* &#x20;Update values field by field:

```javascript
// name = 'John'
{{ui.table.updatedRow.data.name}}
```

* Switch to JS mode (JS button) and send the updated values as an object:

```javascript
{{ui.table.updatedRow.data}}
```

or:

```json
{
  name: "John",
  age: 30
}
```

<figure><img src="/files/Q4zFKA5Xq9pxKBZy29kh" alt=""><figcaption></figcaption></figure>

This object will be sent to the server and converted to an `UPDATE` statement, for example:

```sql
UPDATE users SET name = 'John', age = 30 WHERE id = 23
```

You can check the action's *Payload* tab to see the actual object sent to the server.

{% hint style="danger" %}
If any conditions are specified as *null* or *undefined*, they will be removed from the conditions list. If all conditions are removed, it may result in **updating all rows in the table** if the *Bulk Update* setting is enabled.
{% endhint %}

*Unset fields* will be presented as undefined and will NOT be used in the `UPDATE` statement:

```javascript
{
  id: 23,
  created_at: "2022-10-21",
  // this value will not be sent to the server
  required_at: undefined,
}
```

You can always adjust the data before sending it.

## Examples

### Adding additional values

```javascript
const values = {{ui.form.value}};

return {
  ...values,
  updated_at: new Date(),
}
```

{% hint style="warning" %}
The `created_at` column must exist in the table schema, otherwise it will not be sent.
{% endhint %}

### Changing values

```javascript
const values = {{ui.form.value}};
return {
  ...values,
  name: values.name.toUpperCase(),
}
```

### Deleting unnecessary values

```javascript
const values = {{ui.form.value}};
delete values.age;
return values;
```

or:

```javascript
const values = {{ui.form.value}};
const { updated_at, ...rest } = values;
return rest;
```

### Joining array values

```javascript
const values = {{ui.form.value}};
return {
  ...values,
  tags: values.tags.join(','),
}
```

### Using default values

```javascript
const values = {{ui.form.value}};
return {
  ...values,
  // if the value is not set, use the default value
  created_at: values.created_at || new Date(),
}
```

## Additional settings

If you need to update multiple rows, you can select the [Bulk Update](/reference/working-with-components/table/more-ways-to-use-the-component/select-multiple-rows-in-a-table.md) checkbox in the action's settings.

{% hint style="danger" %}
We recommend being very careful with this setting since it can update all rows in the table.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uibakery.io/reference/working-with-actions/update-row-action.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
