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:
- Is my syntax correct to create one new record with multiple fields filled through user input?
- How do I ensure the user input can be validated as a number for a currency column? My parseFloat() function is still causing errors (scripting block says it cannot create a record because it needs to be a number).
- Both Payment Month and Payment Year are requiring objects, which I assume has to do with the fact that both fields are single select. This is important because I have functions and automations dependent on those being entered the same way every time. How can I alter my code to satisfy that requirement?
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!');