Syntax error in Currency Conversion Scripting by record's date

Hello guys, I have an Airtable managing my bills in multiple currencies.

I’ve been trying to customize the [Airtable Currency Converter]
( to convert each record with the conversation rate of its date. I want it to be automated given that I have 5,000 records of bills.

I suspect my syntax is wrong, but maybe the logic of my code is completely wrong too.

My code is the following :

// load table and records

let table = base.getTable("Table 1");

let result = await table.selectRecordsAsync();

// launch a 'for' loop to fetch conversation rate then update each record depending on value of "Date" field

for (let record of result.records) {


    // fetching exchange rate

    let apiResponse = await fetch(`${record.getCellValue("Date")}?base=EUR`);

    let data = await apiResponse.json();

    let conversionRate = data.rates.GBP;

    // updating the record

    table.updateRecordAsync(record, {

        'Exchange rate': conversionRate,



The code doesn’t work. Thank you for your help / insights / corrections.

Hi @tyloria - you’re pretty close. You’ve got a rogue await in the for loop that is causing the issue. This works:

let table = base.getTable('Table 1');

let query = await table.selectRecordsAsync();

for (let record of query.records) {
    let date = record.getCellValue('Date');
    let apiResponse = await fetch(`${date}?base=EUR`);
    let data = await apiResponse.json();
    let conversionRate = data.rates.GBP;
    table.updateRecordAsync(record, {
        'Exchange rate': conversionRate,
1 Like

Absolutely amazing … The scripting block is so cool for people who don’t really know how to code like me !

thank you @JonathanBowen !

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.