Wix Form - running the VELO code after submission and marking the item in the DB as occupied

Hello to everybody,
I need advice on Wix Forms.
I have a booking form on a dynamic page connected to a CMS item database that works. After sending the form, the customer (including me) will receive a confirmation of the reservation by email.

However, the reserved item is unique and cannot be re-booked by someone else. After submitting the form, I need to mark this item in the database as already occupied. I have a “reserved” field in the database - type boolean, true/false.

I have no idea what code and how to make the change in the database.
I tried to put a button and this code on the page:

export function button16_click(event) {
$w(“#dataset1”).setFieldValue(“reserved”, true);
$w(“#dataset1”).save();
}

But it doesn’t work. Dataset1 is set for write mode.

I also discovered an option to add in Automations the option to perform a NEW TASK - Run the VELO code. But I have no idea what code to enter.

Thanks for any help or guidance on how to do this.

A few things that may help you debug.

I would make sure the dataset is ready by placing the set/save inside a dataset onready call. THinking perhaps the button is being clicked before the dataset is ready maybe

Save also returns a promise so you could add some error handling and see if you are getting an error back or some other information to help.

Docs for reference if you need them