Last active
August 6, 2024 02:22
-
-
Save gregonarash/f1e8ce0b81141c6b3f4b023ffd6a8027 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Substitute "Orders" for table name which contains values | |
//on which you want to run the vlookup | |
let mainTable = base.getTable("Orders"); | |
let mainTableRecords = await mainTable.selectRecordsAsync({fields:["Item.barcode"]}); | |
//Substitute "Product" for table which contains range to search in | |
let lookupTable = base.getTable("Products"); | |
let lookupRangeRecords = await lookupTable.selectRecordsAsync({fields:["Barcode","Name"]}); | |
//Replace "Item.barcode" with column name which has the values you want to look up | |
for (let record of mainTableRecords.records) { | |
let lookupValue = record.getCellValue("Item.barcode"); | |
//Replace "Barcode" with column name which is the range to search in | |
//Replace "Name" with columnn name which value should be returned | |
for (let rangeRecord of lookupRangeRecords.records) { | |
if (rangeRecord.getCellValue("Barcode") === lookupValue) { | |
let returnValue = rangeRecord.getCellValue("Name"); | |
//Replace "Proper Name" with column name from mainTable which should contain the link | |
await mainTable.updateRecordAsync(record, { | |
"Proper Name": returnValue | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment