// Change this to the name of a table in your base let table = base.getTable('Invoices'); // 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.GBP; 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 'Amount (GBP)': record.getCellValue('Amount (USD)') * conversionRate, }); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter