Dec 06, 2022 02:53 PM
I'm very new to scripting and my javascript knowledge from college is a very distant memory, so bear with me. I'm trying to create a script that will essentially generate a mini-form with three fields from my table that will create a new record when filled out.
I've been successful to a point but running into some issues. Code is below. Here are my questions:
Thanks for any help!
// pick table from your base here
let deelTracker = base.getTable('Deel Tracker');
// prompt the user to enter new payments information
output.markdown('# Payment Estimate');
let Payment = await input.textAsync('Payment Estimate');
let Year = await input.textAsync('Payment Year');
let Month = await input.textAsync('Payment Month');
parseFloat(Payment);
// create record
await deelTracker.createRecordAsync(
{
'Payment Estimate': Payment,
'Payment Month': Month,
'Payment Year': Year,
}
);
// confirm
output.text('Thank you!');
Solved! Go to Solution.
Dec 08, 2022 01:05 AM
Hi raechyl, try replacing the createRecordAsync function with this:
await deelTracker.createRecordAsync({
'Payment Estimate': parseFloat(Payment),
'Payment Month': {name: Month},
'Payment Year': {name: Year},
})
I would recommend you look into the possibility of using buttonAsync instead of allowing your users to key in data themselves as typos will throw errors
Dec 07, 2022 02:58 AM
Hi raechyl, could you provide a screenshot of the relevant fields in the table as well, or, even better, a link to an example base with your extension already set up?
Each field type expects its own type of syntax, and the screenshot would be very helpful in determining said types
Having an example base would also save us the work of attempting to recreate your set up for testing and such
Dec 07, 2022 07:10 AM
Thanks for responding!
Here's a link to the example: https://airtable.com/shrExSD0EDV1tTGcQ - let me know if that works for you, or if you need an actual invite sent. Below are a couple screenshots as well.
Thank you!
Dec 08, 2022 01:05 AM
Hi raechyl, try replacing the createRecordAsync function with this:
await deelTracker.createRecordAsync({
'Payment Estimate': parseFloat(Payment),
'Payment Month': {name: Month},
'Payment Year': {name: Year},
})
I would recommend you look into the possibility of using buttonAsync instead of allowing your users to key in data themselves as typos will throw errors
Dec 08, 2022 10:29 AM
Thank you so much, works great!
I did make that edit with buttonsAsync too. Thanks!