Hi - I am new to Script, hoping someone can help me have this function return an array or values rather then just one.
EX) Zip code 10001 exist in multiple cells in “ZIP” and was hoping to return all values associated with 10001, not just one value.
//Substitute “Us Enterprise” for table name which contains values
//on which you want to run the vlookup
let mainTable = base.getTable(“US Enterprise”);
let mainTableRecords = await mainTable.selectRecordsAsync();
//Substitute “ZipCodeData” for table which contains range to search in
let lookupTable = base.getTable(“ZipCodeData”);
let lookupRangeRecords = await lookupTable.selectRecordsAsync();
//Replace "Zip Code " with column name which has the values you want to look up
for (let record of mainTableRecords.records) {
let lookupValue = record.getCellValue("Zip Code");
//Replace "Name" with columnn name which value should be returned
for (let rangeRecord of lookupRangeRecords.records) {
if (rangeRecord.getCellValue("Zip") === lookupValue) {
let returnValue = rangeRecord.getCellValue("Name");
//Replace "Carrier" with update value
await mainTable.updateRecordAsync(record, {
"Carrier": returnValue
});
}
}
}