Help

Convert EUR to USD

Topic Labels: Scripting extentions
1483 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Cody_Arsenault
4 - Data Explorer
4 - Data Explorer

I just ran this script, it made all my prices to 0. Not good. Please help.

I am trying to convert prices from EUR to USD.

I found this script on airtable.

// Change this to the name of a table in your base
let table = base.getTable('Seeds');
// Fetch conversion rate from API - you could change this to any API you want
let apiResponse = await fetch('https://api.exchangerate.host/latest?base=USD');
let data = await apiResponse.json();
let conversionRate = data.rates.EUR;
console.log(`Conversion rate: ${conversionRate}`);
// Update all the records
let result = await table.selectRecordsAsync();
for (let record of result.records) {
    await table.updateRecordAsync(record, {
        // Change these names to fields in your base
        'Price EUR': record.getCellValue('Price USD') * conversionRate,
    });
}
1 Reply 1

Welcome to the Airtable community!

Can you share a screenshot of the log created when running the script?