# Update record

Updating a record from your table means that an already-existing record is updated on one of several of its cells.&#x20;

To exemplify this, we will use a gym booking bot that uses a Table to store who is booked in a yoga class. By updating record, we will add the user as enrolled to the class.&#x20;

This means that you'll go from this:&#x20;

| className | classTeacher | isBooked |
| --------- | ------------ | -------- |
| Zumba     | Monday       | None     |

To this:

<table><thead><tr><th width="250">className</th><th>classTeacher</th><th>isBooked</th></tr></thead><tbody><tr><td>Zumba</td><td>Monday</td><td><strong>Agatha</strong></td></tr></tbody></table>

## Update a record

1. Make sure that you have a well-defined table. For this example, we'll use gym booking table with those fields:
   * **ClassName:** Name of the fitness class.
   * **ClassDay:** Date of the class, in a consistent format (e.g., YYYY-MM-DD).
   * **ClassTime:** Start time of the class, using a clear format (e.g., HH:MM AM/PM).
   * **ClassTeacher:** Name of the instructor leading the class.
   * **IsBooked:** Status field indicating whether the class is booked ('None' or 'Available' by default, updated to customer's name upon booking).

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FawmlIYXnxplQYPAHdOXW%2F1.webp?alt=media&#x26;token=ec8f89bc-30e2-4467-985f-a2b2529b3e37" alt=""><figcaption><p>A table that stores gym class bookings.</p></figcaption></figure>

2. In your bot flow, identify the point in the conversation where the customer chose a class and confirmed their booking.&#x20;
3. [Add a Table operation](https://docs.chatlayer.ai/bot-answers/tables-beta/perform-operations-on-your-records#add-a-table-operation-to-your-flow) to your flow.
4. Choose **Update record** from the list of operations.
5. Select the table that you want to update. For this example, we'll select **Gym class booking**.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FJ2nwV8Kk2KfsLn2qO0iJ%2F2.webp?alt=media&#x26;token=71dc8867-5bf0-4f03-9cb6-8faf79d8815e" alt="" width="375"><figcaption><p>Select the table that you'd like to update.</p></figcaption></figure>

6. Under **Operation Config**, under the isBooked column, add the variable holding the customer's name. In our example, this variable is called `{userName}`. This means that the isBooked column will be updated with `{userName}` as a new value.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FDVYZC4TSiyYHiQmf38ra%2F3.webp?alt=media&#x26;token=8c9d4429-9600-4cd6-8998-efb8c6526371" alt="" width="375"><figcaption><p>Update the isBooked column with the {userName} value.</p></figcaption></figure>

7. Under **Define a selection criteria** **for the records to update**, click on **+ Add filter** to set the conditions to identify which record (or row on your table) should be updated. In our example, the conditions should match the class that the customer is booking. Therefore, we're going to check that `{className}`, `{classDay}`, `{classTeacher}`, and `{classTime}` are already specified.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2F42rmUSu3ZoezP51H6CZd%2F4.webp?alt=media&#x26;token=a04da9bd-adc5-40aa-a82b-3b606f0ef331" alt="" width="375"><figcaption><p>Define selection criteria to define which record (or row on your table) should be updated.</p></figcaption></figure>

8. Optionally, you can set up limits for the number of records to update, in the case where you would like to update more than 1.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2Fh0q535GLx1sKusl8wH1a%2FScreenshot%202024-11-07%20at%2016.03.50.png?alt=media&#x26;token=5a7ec2c2-0fc2-4a81-9d42-158b0ca651ae" alt="" width="367"><figcaption><p>Define how many records to update.</p></figcaption></figure>

9. Click **Save.**

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FfD0fL7IGXp2Vq9VoCn8U%2F5.webp?alt=media&#x26;token=0c125704-7cc0-4a47-8bbb-e9dd551879e7" alt=""><figcaption><p>Your Action block with the Table operation appears on your canvas.</p></figcaption></figure>

10. It's crucial to check the functionality of your **Update record** operation to ensure data is captured and stored correctly. Utilize the emulator to test the flow that you just build.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FffCuswpLjpWSRJwg7UBD%2F6.webp?alt=media&#x26;token=391d8c9a-7d08-4c29-b403-d2f6c166d15a" alt="" width="375"><figcaption><p>Test your Update record flow.</p></figcaption></figure>

11. After completing the booking process in the test, navigate to the updated table (in this example, it's called Gym class booking) to verify the update. Ensure the **isBooked** field is filled with the customers booking the selected class are updated as expected.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FlgPtyZxXamIy7fP8tAij%2F7.webp?alt=media&#x26;token=4f782ff2-3b1e-40f5-b470-d44f2b91cfc3" alt=""><figcaption><p>The Update record operation works on the table as expected.</p></figcaption></figure>

***

{% hint style="success" %}
Looking for a quick and easy bot template to play with Tables? The [Gym bot](https://docs.chatlayer.ai/start-quickly/bot-templates/gym) is a representative use case.
{% endhint %}
