The script is below. I have to tables. Provider AIS API Info and Global APIs.
Field “Provider ID” from the Provider AIS API tab should be looked up in the Global APIs tab, in field Provider ID. The matched records should return the “Is it global?” Field back into the “Global API?” field of the Provider AIS API info tab.
The script is below:
let mainTable = base.getTable("Provider AIS API Info");
let mainTableRecords = await mainTable.selectRecordsAsync();
let lookupTable = base.getTable("Global APIs");
let lookupRangeRecords = await lookupTable.selectRecordsAsync();
for (let record of mainTableRecords.records) {
let lookupValue = record.getCellValue("Provider ID");
for (let rangeRecord of lookupRangeRecords.records) {
if (rangeRecord.getCellValue("Provider Summary") === lookupValue) {
let returnValue = rangeRecord.getCellValue("Is it Global?");
await mainTable.updateRecordAsync(record, {
"Global API?": returnValue
});
}
}
}