I have a script in an Extension I’m running from a button press on a table called “Waitlist”. When I press the button I want it to create a record on the “Reservations” table and link to the Customer that was linked to on the Waitlist. Here is the script I have so far, but it’s not working…any ideas why?
// Define the function that will be called when the button is clicked
async function createReservation() {
// Get the current record that the button was clicked from
const record = input.recordAsync;
// Get the customer name from the current record
const customerName = record.getCellValueAsString(‘Customer’);
// Get the “Reservations” table
const reservationsTable = base.getTable(‘Reservations’);
// Create a new record in the “Reservations” table
await reservationsTable.createRecordAsync({
‘Customer’: customerName,
});
}
Below is the error message I receive.
Where did you get this script? Was it generated from AI?
What is your level of coding experience? Are you interested in learning how to code?
If you are interested in learning to code and starting with AI generated code, I recommend throwing out this bit of code and starting over from scratch using the documentation.
Adding back my final script that I figured out for future reference. It creates a reservation from a waitlist record, adds the customer from the waitlist record as the customer on the reservation, links back to the waitlist record and then marks the Waitlist record as “Reservation Created”.
let table = base.getTable(“Waitlist”);
let record = await input.recordAsync(‘Select a record to update:’,table);
let customerName = record.getCellValue(“Customer”);
let reservationsTable = base.getTable(‘Reservations’);
await reservationsTable.createRecordAsync({
‘Customer’: customerName,
‘Waitlist’: [{id : record.id}]
});
await table.updateRecordAsync(record, {
“Status”: {name: “Reservation Created”}
})
1 Like
Thank you for posting this script. Even though several lines are very similar to your previous version, this version looks so much better!
1 Like