Hi all,
I’m diving into the wonderful world of Airtable scripting with a custom CSV import script that does some data interpretation and creates links to other tables. Starting point was the CSV import example.
I managed to get that working and added more functionality.
Now, I keep getting an error that I cannot seem to solve:
But the editor shows no red markings, and the first line of my script is a comment!
Here are the first few lines of my script:
// Timesheet CSV importer by Emar Vegt
output.text("Note: this script does not handle duplicates yet. You'll have to sort them out yourself.");
// Ask the user to import a CSV file containing a header row
let csvFileResult = await input.fileAsync(
'Upload a timesheet CSV file',
{allowedFileTypes: ['.csv'], hasHeaderRow: true}
);
// The file importer will automatically parse contents for many file types, including CSV files
let csv_rows = csvFileResult.parsedContents;
// Edit this to the name of a table in your base
let timesheet_table = base.getTable('Timesheets');
let person_table = base.getTable('Design team (sync)');
let month_table = base.getTable('Months');
let i_length = csv_rows.length;
let script_progress = 0;
let debug = false;
let should_continue = await input.buttonsAsync(
`Import ${csv_rows.length} records from \"${csvFileResult.file.name}\" into ${timesheet_table.name}?`,
[{label: 'Yes', variant: 'primary'}, 'No', 'Test only']
);
if (should_continue == 'Test only') {
debug = true;
should_continue = 'Yes';
}
if (should_continue === 'Yes') {
Anyone have an idea? Copy-pasting the entire code into a new scripting block also didn’t help.
I have a fair understanding of javascript (and Googling for errors, documentation and ways to achieve what I want) but this one got me stuck.