Re: Lookup script error

734 3
Showing results for 
Search instead for 
Did you mean: 
6 - Interface Innovator
6 - Interface Innovator

Hi, I have written the following script but it’s giving me an error when I run it. Can someone please point out what I’m doing wrong?

let mainTable = base.getTable(“BOOKING DB”);

let mainTableRecords = await mainTable.selectRecordsAsync();

let lookupTable = base.getTable(“LISTING DB”);

let lookupRangeRecords = await lookupTable.selectRecordsAsync();

for (let record of mainTableRecords.records) (

let lookupValue = record.getCellValue("LISTING");

for (let rangeRecord of lookupRangeRecords.records) (

    if (rangeRecord.getCellValue("LISTING") === lookupvalue)

        let returnValue=rangeRecord.getCellValue("ACCOUNT");


            "ACCOUNT"; returnvalue





4 Replies 4

Hello @Hady_Abdelnour and welcome to the Community.

I’m only stopping by here very quickly because I’m overwhelmed with work outside of airtable scripting but hovering over your code, it seems to me that the part I quoted is not functional as is.

You could very usefully use these sources to make it functional:


which are coming from:

and from:

As you are obviously UPDATING records rather than creating new one, you should consult this too:

from this API Documentation:

I don’t know if there are any other issues in your script: sorry for running out of time: it’s seasonal in my work.



Thanks for pointing out my mistake. It helped me and it seems Its good now cause I’m getting no more error notifications anymore but for some reason the column that’s supposed to fill when I’m running the script is not change, keeps empty.

Thanks for your time, especially with how busy you are

Welcome to the Airtable community!

What are the field types of the two matching fields in the different tables? Depending on the two field types, you cannot simply compare the read values. Here are some options:

Option 1: Get the cell values as strings (getCellValueAsString() and compare the strings.

Option 2: Find the exact read format of the fields and make a comparison based on the read values

Thanks :slightly_smiling_face: so much, worked